Skip to content

Commit

Permalink
Select all in text fields with initial focus
Browse files Browse the repository at this point in the history
  • Loading branch information
aspettl authored and Boddlnagg committed Mar 30, 2024
1 parent f8cf40d commit 468bd8b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
3 changes: 1 addition & 2 deletions WordsLive/Editor/RenamePartWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
MinWidth="300" MaxWidth="500"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
WindowStyle="SingleBorderWindow"
FocusManager.FocusedElement="{Binding ElementName=newNameTextBox}">
WindowStyle="SingleBorderWindow">
<DockPanel>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" DockPanel.Dock="Top" Content="{x:Static resx:Resource.rpNewNameLabel}"/>
<TextBox x:Name="newNameTextBox" Height="Auto" Margin="5" DockPanel.Dock="Top" Style="{StaticResource textBoxInError}">
Expand Down
6 changes: 6 additions & 0 deletions WordsLive/Editor/RenamePartWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public RenamePartWindow(Song song, SongPart part)
{
this.PartName = this.part.Name;
}

this.Loaded += delegate
{
this.newNameTextBox.Focus();
this.newNameTextBox.SelectAll();
};
}

public string PartName
Expand Down
3 changes: 1 addition & 2 deletions WordsLive/Editor/RenameSongWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
MinWidth="300" MaxWidth="500"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
WindowStyle="SingleBorderWindow"
FocusManager.FocusedElement="{Binding ElementName=newNameTextBox}">
WindowStyle="SingleBorderWindow">
<StackPanel Orientation="Vertical">
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="{x:Static resx:Resource.rsNewNameLabel}"/>
<TextBox x:Name="newNameTextBox" Height="Auto" Margin="5" Style="{StaticResource textBoxInError}">
Expand Down
6 changes: 6 additions & 0 deletions WordsLive/Editor/RenameSongWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public RenameSongWindow(string songName)
InitializeComponent();
this.SongName = songName;
this.DataContext = this;

this.Loaded += delegate
{
this.newNameTextBox.Focus();
this.newNameTextBox.SelectAll();
};
}

private void Button_Click(object sender, RoutedEventArgs e)
Expand Down
6 changes: 6 additions & 0 deletions WordsLive/Editor/SaveFilenameDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public SaveFilenameDialog(string name)

this.DataContext = this;
this.FilenameWithoutExtension = name;

this.Loaded += delegate
{
this.filenameTextBox.Focus();
this.filenameTextBox.SelectAll();
};
}

public string FilenameWithoutExtension
Expand Down

0 comments on commit 468bd8b

Please sign in to comment.