Skip to content
This repository has been archived by the owner on Aug 26, 2018. It is now read-only.

Commit

Permalink
Close #4 - Если вне фокуса начинаешь вводить цифры, то они должны вво…
Browse files Browse the repository at this point in the history
…диться.
  • Loading branch information
pongo committed Jul 4, 2014
1 parent ad8e5b9 commit 80f5863
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orzeszek Timer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<Window x:Class="OrzeszekTimer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Orzeszek Timer" Height="150" Width="300" Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged" Closing="Window_Closing" Closed="Window_Closed" Activated="Window_Activated" Deactivated="Window_Deactivated" MouseUp="Window_MouseUp" KeyUp="Window_KeyUp">
Title="Orzeszek Timer" Height="150" Width="300" Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged" Closing="Window_Closing" Closed="Window_Closed" Activated="Window_Activated" Deactivated="Window_Deactivated" MouseUp="Window_MouseUp" KeyUp="Window_KeyUp" KeyDown="Window_KeyDown">
<Window.Resources>
<ControlTemplate x:Key="ValidTextBoxTemplate" TargetType="{x:Type TextBox}">
<Border x:Name="Border" Background="#FFFFFF" BorderBrush="#DDDDDD" BorderThickness="1" Padding="1" SnapsToDevicePixels="True">
Expand Down
12 changes: 12 additions & 0 deletions Orzeszek Timer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -791,5 +791,17 @@ private void MainTextBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEv
((TextBox)sender).SelectAll();
}
}

private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (!this.MainTextBox.IsKeyboardFocused
&&
((e.Key >= Key.A && e.Key <= Key.Z)
|| (e.Key >= Key.D0 && e.Key <= Key.D9)
|| (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)))
{
this.MainTextBox.Focus();
}
}
}
}

0 comments on commit 80f5863

Please sign in to comment.