Skip to content

Commit 7f01fae

Browse files
committed
code_style: remove unnecessary AutoFocusBehaviour
Signed-off-by: leo <longshuang@msn.cn>
1 parent e5f621f commit 7f01fae

13 files changed

+43
-62
lines changed

src/Views/Askpass.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
Focusable="True"
4747
PasswordChar="*"
4848
RevealPassword="{Binding #ToggleShowPassword.IsChecked, Mode=OneWay}"
49-
HorizontalAlignment="Stretch"
50-
v:AutoFocusBehaviour.IsEnabled="True">
49+
HorizontalAlignment="Stretch">
5150
<TextBox.InnerRightContent>
5251
<ToggleButton Grid.Column="6"
5352
x:Name="ToggleShowPassword"

src/Views/Askpass.axaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
3+
using Avalonia.Input;
24
using Avalonia.Interactivity;
35

46
namespace SourceGit.Views
@@ -10,6 +12,12 @@ public Askpass()
1012
InitializeComponent();
1113
}
1214

15+
protected override void OnLoaded(RoutedEventArgs e)
16+
{
17+
base.OnLoaded(e);
18+
TxtPassphrase.Focus(NavigationMethod.Directional);
19+
}
20+
1321
private void CloseWindow(object _1, RoutedEventArgs _2)
1422
{
1523
Console.Out.WriteLine("No passphrase entered.");

src/Views/AutoFocusBehaviour.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Views/LauncherPagesCommandPalette.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:vm="using:SourceGit.ViewModels"
6-
xmlns:v="using:SourceGit.Views"
76
xmlns:c="using:SourceGit.Converters"
87
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
98
x:Class="SourceGit.Views.LauncherPagesCommandPalette"
@@ -17,8 +16,7 @@
1716
CornerRadius="12"
1817
Text="{Binding SearchFilter, Mode=TwoWay}"
1918
BorderBrush="{DynamicResource Brush.Border2}"
20-
VerticalContentAlignment="Center"
21-
v:AutoFocusBehaviour.IsEnabled="True">
19+
VerticalContentAlignment="Center">
2220
<TextBox.InnerLeftContent>
2321
<Path Width="14" Height="14"
2422
Margin="6,0,0,0"

src/Views/LauncherPagesCommandPalette.axaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Avalonia.Controls;
22
using Avalonia.Input;
3+
using Avalonia.Interactivity;
34

45
namespace SourceGit.Views
56
{
@@ -10,6 +11,12 @@ public LauncherPagesCommandPalette()
1011
InitializeComponent();
1112
}
1213

14+
protected override void OnLoaded(RoutedEventArgs e)
15+
{
16+
base.OnLoaded(e);
17+
FilterTextBox.Focus(NavigationMethod.Directional);
18+
}
19+
1320
protected override void OnKeyDown(KeyEventArgs e)
1421
{
1522
base.OnKeyDown(e);

src/Views/PushToNewBranch.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
MinWidth="300" Height="32"
4444
Margin="16,8,16,0"
4545
CornerRadius="3"
46-
Focusable="True"
47-
v:AutoFocusBehaviour.IsEnabled="True">
46+
Focusable="True">
4847
<TextBox.InnerLeftContent>
4948
<Border Height="22" CornerRadius="10" Margin="4,0,0,0" Background="Green">
5049
<TextBlock x:Name="TxtPrefix" Text="REMOTE" Foreground="White" Margin="8,0"/>

src/Views/PushToNewBranch.axaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Avalonia.Input;
12
using Avalonia.Interactivity;
23

34
namespace SourceGit.Views
@@ -10,6 +11,12 @@ public PushToNewBranch()
1011
InitializeComponent();
1112
}
1213

14+
protected override void OnLoaded(RoutedEventArgs e)
15+
{
16+
base.OnLoaded(e);
17+
TxtName.Focus(NavigationMethod.Directional);
18+
}
19+
1320
public void SetRemote(string remote)
1421
{
1522
TxtPrefix.Text = remote;

src/Views/RepositoryCommandPalette.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
CornerRadius="12"
1818
Text="{Binding Filter, Mode=TwoWay}"
1919
BorderBrush="{DynamicResource Brush.Border2}"
20-
VerticalContentAlignment="Center"
21-
v:AutoFocusBehaviour.IsEnabled="True">
20+
VerticalContentAlignment="Center">
2221
<TextBox.InnerLeftContent>
2322
<Path Width="14" Height="14"
2423
Margin="6,0,0,0"

src/Views/RepositoryCommandPalette.axaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Avalonia.Controls;
22
using Avalonia.Input;
3+
using Avalonia.Interactivity;
34

45
namespace SourceGit.Views
56
{
@@ -10,6 +11,12 @@ public RepositoryCommandPalette()
1011
InitializeComponent();
1112
}
1213

14+
protected override void OnLoaded(RoutedEventArgs e)
15+
{
16+
base.OnLoaded(e);
17+
FilterTextBox.Focus(NavigationMethod.Directional);
18+
}
19+
1320
protected override void OnKeyDown(KeyEventArgs e)
1421
{
1522
base.OnKeyDown(e);

src/Views/RepositoryCommandPaletteTextBox.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
using System;
22

3-
using Avalonia;
43
using Avalonia.Controls;
54
using Avalonia.Input;
5+
using Avalonia.Interactivity;
66

77
namespace SourceGit.Views
88
{
99
public class RepositoryCommandPaletteTextBox : TextBox
1010
{
1111
protected override Type StyleKeyOverride => typeof(TextBox);
1212

13+
protected override void OnLoaded(RoutedEventArgs e)
14+
{
15+
base.OnLoaded(e);
16+
Focus(NavigationMethod.Directional);
17+
}
18+
1319
protected override void OnKeyDown(KeyEventArgs e)
1420
{
1521
if (e.Key == Key.Back && string.IsNullOrEmpty(Text))
@@ -25,11 +31,5 @@ protected override void OnKeyDown(KeyEventArgs e)
2531

2632
base.OnKeyDown(e);
2733
}
28-
29-
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
30-
{
31-
base.OnAttachedToVisualTree(e);
32-
Focus();
33-
}
3434
}
3535
}

0 commit comments

Comments
 (0)