chat: make sure that CTRL is the /only/ modifier key pressed when detecting ctrl+a etc
authorsheepluva
Sun, 12 Jul 2015 23:15:39 +0200
changeset 11004 bd62cdbea391
parent 11003 9e4baaeade99
child 11005 71927bdb776a
chat: make sure that CTRL is the /only/ modifier key pressed when detecting ctrl+a etc
hedgewars/uChat.pas
--- a/hedgewars/uChat.pas	Sun Jul 12 08:20:33 2015 +0200
+++ b/hedgewars/uChat.pas	Sun Jul 12 23:15:39 2015 +0200
@@ -794,9 +794,10 @@
 
 procedure KeyPressChat(Key, Sym: Longword; Modifier: Word);
 const firstByteMark: array[0..3] of byte = (0, $C0, $E0, $F0);
+      nonStateMask = (not (KMOD_NUM or KMOD_CAPS));
 var i, btw, index: integer;
     utf8: shortstring;
-    action, selMode, ctrl: boolean;
+    action, selMode, ctrl, ctrlonly: boolean;
     skip: TCharSkip;
 begin
     LastKeyPressTick:= RealTicks;
@@ -806,6 +807,7 @@
 
     selMode:= (modifier and (KMOD_LSHIFT or KMOD_RSHIFT)) <> 0;
     ctrl:= (modifier and (KMOD_LCTRL or KMOD_RCTRL)) <> 0;
+    ctrlonly:= ctrl and ((modifier and nonStateMask and (not (KMOD_LCTRL or KMOD_RCTRL))) = 0);
     skip:= none;
 
     case Sym of
@@ -965,7 +967,7 @@
         SDLK_a:
             begin
             // select all
-            if ctrl then
+            if ctrlonly then
                 begin
                 ResetSelection();
                 cursorPos:= 0;
@@ -979,7 +981,7 @@
         SDLK_c:
             begin
             // copy
-            if ctrl then
+            if ctrlonly then
                 CopySelectionToClipboard()
             else
                 action:= false;
@@ -987,7 +989,7 @@
         SDLK_v:
             begin
             // paste
-            if ctrl then
+            if ctrlonly then
                 begin
                 DeleteSelected();
                 PasteFromClipboard();
@@ -998,7 +1000,7 @@
         SDLK_x:
             begin
             // cut
-            if ctrl then
+            if ctrlonly then
                 begin
                 CopySelectionToClipboard();
                 DeleteSelected();