Select the text in the textbox once it gets focus, for a more user-friendly browsing experience.

This commit is contained in:
Per Lundberg
2013-07-30 22:38:31 +03:00
parent 106f433597
commit 75d1fef4e1
2 changed files with 16 additions and 2 deletions
@@ -29,8 +29,9 @@
DockPanel.Dock="Right"
Command="{Binding GoCommand}">Go</Button>
<TextBox Height="23"
Name="urlTextBox"
Text="{Binding AddressEditable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
Text="{Binding AddressEditable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
GotKeyboardFocus="OnTextBoxGotKeyboardFocus"
GotMouseCapture="OnTextBoxGotMouseCapture">
<TextBox.InputBindings>
<KeyBinding Key="Enter"
Command="{Binding GoCommand}" />
@@ -1,4 +1,5 @@
using System.Windows.Controls;
using System.Windows.Input;
namespace CefSharp.Wpf.Example.Views.Main
{
@@ -8,5 +9,17 @@ namespace CefSharp.Wpf.Example.Views.Main
{
InitializeComponent();
}
private void OnTextBoxGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
var textBox = (TextBox) sender;
textBox.SelectAll();
}
private void OnTextBoxGotMouseCapture(object sender, MouseEventArgs e)
{
var textBox = (TextBox) sender;
textBox.SelectAll();
}
}
}