From d4fcdf31996130a4d86720c1fdea6e74d2f6af0e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 10 Jan 2016 00:59:10 +1100 Subject: [PATCH] Use proper key press, instead of looking for KeyDown event. --- .../2D/Screens/Menu/HacksSettingsScreen.cs | 4 ++-- .../2D/Widgets/Chat/TextInputWidget.Handlers.cs | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs index e7bfad3ab..74f87b55d 100644 --- a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs @@ -93,9 +93,9 @@ namespace ClassicalSharp { LocalPlayer p = game.LocalPlayer; bool noGlobalHacks = !p.CanAnyHacks || !p.HacksEnabled; buttons[3].Disabled = noGlobalHacks || !p.CanSpeed; - buttons[5].Disabled = noGlobalHacks || !p.CanSpeed; + buttons[4].Disabled = noGlobalHacks || !p.CanSpeed; buttons[6].Disabled = noGlobalHacks || !p.CanPushbackBlocks; - buttons[6].Disabled = true; // TODO: get this working + buttons[4].Disabled = true; // TODO: get this working } ButtonWidget Make( int x, int y, string text, Action onClick, diff --git a/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs b/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs index f4009901a..f88f99dfc 100644 --- a/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs +++ b/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs @@ -7,14 +7,12 @@ using System.Windows.Forms; namespace ClassicalSharp { public sealed partial class TextInputWidget : Widget { - - bool supressNextPress = false; public override bool HandlesKeyPress( char key ) { - if( game.HideGui || supressNextPress ) { - supressNextPress = false; - return true; + if( key == '`' ) { + TildeKey(); return true; // TODO: use tab instead of tilde } + if( game.HideGui ) return true; if( chatInputText.Length < len && IsValidInputChar( key ) && key != '&' ) { if( caretPos == -1 ) { @@ -35,8 +33,7 @@ namespace ClassicalSharp { return key < Key.F1 || key > Key.F35; bool controlDown = game.IsKeyDown( Key.ControlLeft ) || game.IsKeyDown( Key.ControlRight ); - /*if( key == Key.Tilde ) TildeKey(); TODO: Support properly on non-standard keyboard layouts. - else*/ if( key == Key.Down ) DownKey( controlDown ); + if( key == Key.Down ) DownKey( controlDown ); else if( key == Key.Up ) UpKey( controlDown ); else if( key == Key.Left ) LeftKey( controlDown ); else if( key == Key.Right ) RightKey( controlDown ); @@ -56,7 +53,6 @@ namespace ClassicalSharp { int pos = caretPos == -1 ? chatInputText.Length - 1 : caretPos; int start = pos; char[] value = chatInputText.value; - supressNextPress = true; while( start >= 0 && Char.IsLetterOrDigit( value[start] ) ) start--;