summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a24522e)
raw | patch | inline | side by side (parent: a24522e)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 4 Aug 2017 04:38:40 +0000 (07:38 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 4 Aug 2017 05:16:14 +0000 (08:16 +0300) |
src/game/g_gui.pas | patch | blob | history |
diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas
index fbab591b37059bcbad512a6615e9f4f88067c78d..22cb48d1e4317c46a4f39adcb2f98115741d8ded 100644 (file)
--- a/src/game/g_gui.pas
+++ b/src/game/g_gui.pas
procedure OnMessage(var Msg: TMessage); virtual;
procedure Update; virtual;
procedure Draw; virtual;
+ function WantActivationKey (key: LongInt): Boolean; virtual;
property X: Integer read FX write FX;
property Y: Integer read FY write FY;
property Enabled: Boolean read FEnabled write FEnabled;
procedure OnMessage(var Msg: TMessage); override;
procedure Draw; override;
function GetWidth(): Word;
+ function WantActivationKey (key: LongInt): Boolean; override;
property Key: Word read FKey write FKey;
property Color: TRGB read FColor write FColor;
property Font: TFont read FFont write FFont;
procedure TGUIControl.Update();
begin
-
end;
procedure TGUIControl.Draw();
begin
+end;
+function TGUIControl.WantActivationKey (key: LongInt): Boolean;
+begin
+ result := false;
end;
{ TGUITextButton }
if not ok then Exit;
+ if (Msg.Msg = WM_KEYDOWN) and (FIndex <> -1) and (FItems[FIndex].Control <> nil) and
+ (FItems[FIndex].Control.WantActivationKey(Msg.wParam)) then
+ begin
+ FItems[FIndex].Control.OnMessage(Msg);
+ g_Sound_PlayEx(MENU_CLICKSOUND);
+ exit;
+ end;
+
case Msg.Msg of
WM_KEYDOWN:
begin
if FItems[FIndex].Control <> nil then
FItems[FIndex].Control.OnMessage(Msg);
end;
- IK_RETURN, IK_KPRETURN, IK_BACKSPACE:
+ IK_RETURN, IK_KPRETURN:
begin
if FIndex <> -1 then
begin
if w > Result then Result := w;
end;
+function TGUIKeyRead.WantActivationKey (key: LongInt): Boolean;
+begin
+ result :=
+ (key = IK_BACKSPACE) or
+ (key = IK_LEFT) or (key = IK_RIGHT) or
+ (key = IK_KPLEFT) or (key = IK_KPRIGHT) or
+ false; // oops
+end;
+
procedure TGUIKeyRead.OnMessage(var Msg: TMessage);
procedure actDefCtl ();
begin