mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-23 18:30:34 +08:00
enhance: add Views.StealHotKey.Enter to use hotkey Enter to start popup directly without checking focused TextBox (#1606)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
Text="{Binding #ThisControl.Subject, Mode=TwoWay}"
|
||||
Watermark="{DynamicResource Text.CommitMessageTextBox.SubjectPlaceholder}"
|
||||
PreviewKeyDown="OnSubjectTextBoxPreviewKeyDown"/>
|
||||
PreviewKeyDown="OnSubjectTextBoxPreviewKeyDown"
|
||||
Tag="{Binding Source={x:Static v:StealHotKey.Enter}}"/>
|
||||
|
||||
<Rectangle Grid.Row="1"
|
||||
Height="1"
|
||||
@@ -51,7 +52,8 @@
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Text="{Binding #ThisControl.Description, Mode=TwoWay}"
|
||||
Watermark="{DynamicResource Text.CommitMessageTextBox.MessagePlaceholder}"
|
||||
PreviewKeyDown="OnDescriptionTextBoxPreviewKeyDown"/>
|
||||
PreviewKeyDown="OnDescriptionTextBoxPreviewKeyDown"
|
||||
Tag="{Binding Source={x:Static v:StealHotKey.Enter}}"/>
|
||||
|
||||
<Rectangle Grid.Row="3"
|
||||
Height="1"
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
CornerRadius="2"
|
||||
Watermark="{DynamicResource Text.CreateTag.Message.Placeholder}"
|
||||
Text="{Binding Message, Mode=TwoWay}"
|
||||
IsVisible="{Binding Annotated}"/>
|
||||
IsVisible="{Binding Annotated}"
|
||||
Tag="{Binding Source={x:Static v:StealHotKey.Enter}}"/>
|
||||
|
||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||
Height="32" Margin="0,4,0,0"
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace SourceGit.Views
|
||||
var children = this.GetLogicalDescendants();
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (child is TextBox { IsFocused: true } textBox)
|
||||
if (child is TextBox { IsFocused: true, Tag: StealHotKey steal } textBox &&
|
||||
steal is { Key: Key.Enter, KeyModifiers: KeyModifiers.None })
|
||||
{
|
||||
var fake = new KeyEventArgs()
|
||||
{
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
AcceptsTab="True"
|
||||
VerticalContentAlignment="Top"
|
||||
Padding="4"
|
||||
v:AutoFocusBehaviour.IsEnabled="True"/>
|
||||
v:AutoFocusBehaviour.IsEnabled="True"
|
||||
Tag="{Binding Source={x:Static v:StealHotKey.Enter}}"/>
|
||||
|
||||
<CheckBox Grid.Row="2" Grid.Column="1"
|
||||
Height="32"
|
||||
|
||||
12
src/Views/StealHotKey.cs
Normal file
12
src/Views/StealHotKey.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public class StealHotKey(Key key, KeyModifiers keyModifiers = KeyModifiers.None)
|
||||
{
|
||||
public Key Key { get; } = key;
|
||||
public KeyModifiers KeyModifiers { get; } = keyModifiers;
|
||||
|
||||
public static StealHotKey Enter { get; } = new StealHotKey(Key.Enter);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user