summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e4428a8)
raw | patch | inline | side by side (parent: e4428a8)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 4 Oct 2017 13:37:20 +0000 (16:37 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 4 Oct 2017 13:38:15 +0000 (16:38 +0300) |
index 50a73f13b8f736be4339ba2118fadc85404277e2..27f14fd0fd007acfcca858be4f6fff6278e08daa 100644 (file)
--- a/src/flexui/fui_ctls.pas
+++ b/src/flexui/fui_ctls.pas
procedure doAction (); virtual; // so user controls can override it
- procedure mouseEvent (var ev: THMouseEvent); virtual; // returns `true` if event was eaten
- procedure keyEvent (var ev: THKeyEvent); virtual; // returns `true` if event was eaten
- procedure keyEventPre (var ev: THKeyEvent); virtual; // will be called before dispatching the event
- procedure keyEventPost (var ev: THKeyEvent); virtual; // will be called after if nobody processed the event
+ procedure mouseEvent (var ev: TFUIMouseEvent); virtual; // returns `true` if event was eaten
+ procedure keyEvent (var ev: TFUIKeyEvent); virtual; // returns `true` if event was eaten
+ procedure keyEventPre (var ev: TFUIKeyEvent); virtual; // will be called before dispatching the event
+ procedure keyEventPost (var ev: TFUIKeyEvent); virtual; // will be called after if nobody processed the event
function prevSibling (): TUIControl;
function nextSibling (): TUIControl;
procedure drawControl (gx, gy: Integer); override;
procedure drawControlPost (gx, gy: Integer); override;
- procedure keyEvent (var ev: THKeyEvent); override; // returns `true` if event was eaten
- procedure mouseEvent (var ev: THMouseEvent); override; // returns `true` if event was eaten
+ procedure keyEvent (var ev: TFUIKeyEvent); override; // returns `true` if event was eaten
+ procedure mouseEvent (var ev: TFUIMouseEvent); override; // returns `true` if event was eaten
public
property freeOnClose: Boolean read mFreeOnClose write mFreeOnClose;
procedure drawControl (gx, gy: Integer); override;
- procedure mouseEvent (var ev: THMouseEvent); override;
- procedure keyEvent (var ev: THKeyEvent); override;
+ procedure mouseEvent (var ev: TFUIMouseEvent); override;
+ procedure keyEvent (var ev: TFUIKeyEvent); override;
public
property caption: AnsiString read mCaption write setCaption;
procedure drawControl (gx, gy: Integer); override;
- procedure mouseEvent (var ev: THMouseEvent); override;
- procedure keyEventPost (var ev: THKeyEvent); override;
+ procedure mouseEvent (var ev: TFUIMouseEvent); override;
+ procedure keyEventPost (var ev: TFUIKeyEvent); override;
public
property text: AnsiString read mText write setText;
procedure drawControl (gx, gy: Integer); override;
- procedure mouseEvent (var ev: THMouseEvent); override;
- procedure keyEvent (var ev: THKeyEvent); override;
+ procedure mouseEvent (var ev: TFUIMouseEvent); override;
+ procedure keyEvent (var ev: TFUIKeyEvent); override;
end;
// ////////////////////////////////////////////////////////////////////// //
procedure drawControl (gx, gy: Integer); override;
- procedure mouseEvent (var ev: THMouseEvent); override;
- procedure keyEvent (var ev: THKeyEvent); override;
+ procedure mouseEvent (var ev: TFUIMouseEvent); override;
+ procedure keyEvent (var ev: TFUIKeyEvent); override;
procedure setVar (pvar: PBoolean);
// ////////////////////////////////////////////////////////////////////////// //
-procedure uiMouseEvent (var evt: THMouseEvent);
-procedure uiKeyEvent (var evt: THKeyEvent);
+procedure uiMouseEvent (var evt: TFUIMouseEvent);
+procedure uiKeyEvent (var evt: TFUIKeyEvent);
procedure uiDraw ();
procedure uiFocus ();
end;
-procedure uiMouseEvent (var evt: THMouseEvent);
+procedure uiMouseEvent (var evt: TFUIMouseEvent);
var
- ev: THMouseEvent;
+ ev: TFUIMouseEvent;
f, c: Integer;
lx, ly: Integer;
ctmp: TUIControl;
begin
processKills();
- if (evt.eaten) or (evt.cancelled) then exit;
+ if (not evt.alive) then exit;
ev := evt;
ev.x := trunc(ev.x/fuiRenderScale);
ev.y := trunc(ev.y/fuiRenderScale);
exit;
end;
if (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then uiTopList[High(uiTopList)].mouseEvent(ev);
- if (not ev.eaten) and (not ev.cancelled) and (ev.press) then
+ if (ev.alive) and (ev.press) then
begin
for f := High(uiTopList) downto 0 do
begin
end;
-procedure uiKeyEvent (var evt: THKeyEvent);
+procedure uiKeyEvent (var evt: TFUIKeyEvent);
var
- ev: THKeyEvent;
+ ev: TFUIKeyEvent;
begin
processKills();
- if (evt.eaten) or (evt.cancelled) then exit;
+ if (not evt.alive) then exit;
ev := evt;
ev.x := trunc(ev.x/fuiRenderScale);
ev.y := trunc(ev.y/fuiRenderScale);
// ////////////////////////////////////////////////////////////////////////// //
-procedure TUIControl.mouseEvent (var ev: THMouseEvent);
+procedure TUIControl.mouseEvent (var ev: TFUIMouseEvent);
var
ctl: TUIControl;
begin
end;
-procedure TUIControl.keyEvent (var ev: THKeyEvent);
+procedure TUIControl.keyEvent (var ev: TFUIKeyEvent);
function doPreKey (ctl: TUIControl): Boolean;
begin
if (not ctl.enabled) then begin result := false; exit; end;
ctl.keyEventPre(ev);
- result := (ev.eaten) or (ev.cancelled); // stop if event was consumed
+ result := (not ev.alive); // stop if event was consumed
end;
function doPostKey (ctl: TUIControl): Boolean;
begin
if (not ctl.enabled) then begin result := false; exit; end;
ctl.keyEventPost(ev);
- result := (ev.eaten) or (ev.cancelled); // stop if event was consumed
+ result := (not ev.alive); // stop if event was consumed
end;
var
ctl: TUIControl;
begin
if (not enabled) then exit;
- if (ev.eaten) or (ev.cancelled) then exit;
+ if (not ev.alive) then exit;
// call pre-key
if (mParent = nil) then
begin
forEachControl(doPreKey);
- if (ev.eaten) or (ev.cancelled) then exit;
+ if (not ev.alive) then exit;
end;
// focused control should process keyboard first
if (topLevel.mFocused <> self) and isMyChild(topLevel.mFocused) and (topLevel.mFocused.enabled) then
while (ctl <> nil) and (ctl <> self) do
begin
ctl.keyEvent(ev);
- if (ev.eaten) or (ev.cancelled) then exit;
+ if (not ev.alive) then exit;
ctl := ctl.mParent;
end;
end;
exit;
end;
// call post-keys
- if (ev.eaten) or (ev.cancelled) then exit;
+ if (not ev.alive) then exit;
forEachControl(doPostKey);
end;
end;
-procedure TUIControl.keyEventPre (var ev: THKeyEvent);
+procedure TUIControl.keyEventPre (var ev: TFUIKeyEvent);
begin
end;
-procedure TUIControl.keyEventPost (var ev: THKeyEvent);
+procedure TUIControl.keyEventPost (var ev: TFUIKeyEvent);
begin
end;
end;
-procedure TUITopWindow.keyEvent (var ev: THKeyEvent);
+procedure TUITopWindow.keyEvent (var ev: TFUIKeyEvent);
begin
inherited keyEvent(ev);
- if (ev.eaten) or (ev.cancelled) or (not enabled) {or (not getFocused)} then exit;
+ if (not ev.alive) or (not enabled) {or (not getFocused)} then exit;
if (ev = 'M-F3') then
begin
if (not assigned(closeRequestCB)) or (closeRequestCB(self)) then
end;
-procedure TUITopWindow.mouseEvent (var ev: THMouseEvent);
+procedure TUITopWindow.mouseEvent (var ev: TFUIMouseEvent);
var
lx, ly: Integer;
vhgt, ytop: Integer;
end;
-procedure TUIBox.mouseEvent (var ev: THMouseEvent);
+procedure TUIBox.mouseEvent (var ev: TFUIMouseEvent);
var
lx, ly: Integer;
begin
inherited mouseEvent(ev);
- if (not ev.eaten) and (not ev.cancelled) and (enabled) and toLocal(ev.x, ev.y, lx, ly) then
+ if (ev.alive) and (enabled) and toLocal(ev.x, ev.y, lx, ly) then
begin
ev.eat();
end;
end;
-procedure TUIBox.keyEvent (var ev: THKeyEvent);
+procedure TUIBox.keyEvent (var ev: TFUIKeyEvent);
var
dir: Integer = 0;
cur, ctl: TUIControl;
begin
inherited keyEvent(ev);
- if (ev.eaten) or (ev.cancelled) or (not ev.press) or (not enabled) or (not getActive) then exit;
+ if (not ev.alive) or (not ev.press) or (not enabled) or (not getActive) then exit;
if (Length(mChildren) = 0) then exit;
if (mHoriz) and (ev = 'Left') then dir := -1
else if (mHoriz) and (ev = 'Right') then dir := 1
end;
-procedure TUITextLabel.mouseEvent (var ev: THMouseEvent);
+procedure TUITextLabel.mouseEvent (var ev: TFUIMouseEvent);
var
lx, ly: Integer;
begin
inherited mouseEvent(ev);
- if (not ev.eaten) and (not ev.cancelled) and (enabled) and toLocal(ev.x, ev.y, lx, ly) then
+ if (ev.alive) and (enabled) and toLocal(ev.x, ev.y, lx, ly) then
begin
ev.eat();
end;
end;
-procedure TUITextLabel.keyEventPost (var ev: THKeyEvent);
+procedure TUITextLabel.keyEventPost (var ev: TFUIKeyEvent);
begin
if (not enabled) then exit;
if (mHotChar = #0) then exit;
- if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
+ if (not ev.alive) or (not ev.press) then exit;
if (ev.kstate <> ev.ModAlt) then exit;
if (not ev.isHot(mHotChar)) then exit;
ev.eat();
end;
-procedure TUIButton.mouseEvent (var ev: THMouseEvent);
+procedure TUIButton.mouseEvent (var ev: TFUIMouseEvent);
var
lx, ly: Integer;
begin
end;
exit;
end;
- if (ev.eaten) or (ev.cancelled) or (not enabled) or not focused then exit;
+ if (not ev.alive) or (not enabled) or (not focused) then exit;
mPushed := true;
ev.eat();
end;
-procedure TUIButton.keyEvent (var ev: THKeyEvent);
+procedure TUIButton.keyEvent (var ev: TFUIKeyEvent);
begin
inherited keyEvent(ev);
- if (not ev.eaten) and (not ev.cancelled) and (enabled) then
+ if (ev.alive) and (enabled) then
begin
if (ev = '+Enter') or (ev = '+Space') then
begin
end;
-procedure TUISwitchBox.mouseEvent (var ev: THMouseEvent);
+procedure TUISwitchBox.mouseEvent (var ev: TFUIMouseEvent);
var
lx, ly: Integer;
begin
end;
exit;
end;
- if (ev.eaten) or (ev.cancelled) or (not enabled) or not focused then exit;
+ if (not ev.alive) or (not enabled) or not focused then exit;
ev.eat();
end;
-procedure TUISwitchBox.keyEvent (var ev: THKeyEvent);
+procedure TUISwitchBox.keyEvent (var ev: TFUIKeyEvent);
begin
inherited keyEvent(ev);
- if (not ev.eaten) and (not ev.cancelled) and (enabled) then
+ if (ev.alive) and (enabled) then
begin
if (ev = 'Space') then
begin
index 919227aeb87f30f27a49c680b96f363286b61b20..110833f92d4f2adb47abeb945d6c7ff18309275b 100644 (file)
// ////////////////////////////////////////////////////////////////////////// //
type
- THMouseEvent = record
+ TFUIMouseEvent = record
public
const
// both for but and for bstate
dx, dy: Integer; // for wheel this is wheel motion, otherwise this is relative mouse motion
but: Word; // current pressed/released button, or 0 for motion
bstate: Word; // button state BEFORE event (i.e. press/release modifications aren't done yet)
- kstate: Word; // keyboard state (see THKeyEvent);
+ kstate: Word; // keyboard state (see TFUIKeyEvent);
public
procedure intrInit (); inline; // init hidden fields
function press (): Boolean; inline;
function release (): Boolean; inline;
function motion (): Boolean; inline;
+ function isAlive (): Boolean; inline;
procedure eat (); inline;
procedure cancel (); inline;
public
property eaten: Boolean read mEaten;
property cancelled: Boolean read mCancelled;
+ property alive: Boolean read isAlive; // not eaten and not cancelled
end;
- THKeyEvent = record
+ TFUIKeyEvent = record
public
const
// modifiers
function press (): Boolean; inline;
function release (): Boolean; inline;
+ function isAlive (): Boolean; inline;
procedure eat (); inline;
procedure cancel (); inline;
public
property eaten: Boolean read mEaten;
property cancelled: Boolean read mCancelled;
+ property alive: Boolean read isAlive; // not eaten and not cancelled
end;
// ////////////////////////////////////////////////////////////////////////// //
// event handlers
var
- evMouseCB: procedure (var ev: THMouseEvent) = nil;
- evKeyCB: procedure (var ev: THKeyEvent) = nil;
+ evMouseCB: procedure (var ev: TFUIMouseEvent) = nil;
+ evKeyCB: procedure (var ev: TFUIKeyEvent) = nil;
// ////////////////////////////////////////////////////////////////////////// //
// any mods = 255: nothing was defined
function parseModKeys (const s: AnsiString; out kmods: Byte; out mbuts: Byte): AnsiString;
-operator = (constref ev: THKeyEvent; const s: AnsiString): Boolean;
-operator = (const s: AnsiString; constref ev: THKeyEvent): Boolean;
+operator = (constref ev: TFUIKeyEvent; const s: AnsiString): Boolean;
+operator = (const s: AnsiString; constref ev: TFUIKeyEvent): Boolean;
-operator = (constref ev: THMouseEvent; const s: AnsiString): Boolean;
-operator = (const s: AnsiString; constref ev: THMouseEvent): Boolean;
+operator = (constref ev: TFUIMouseEvent; const s: AnsiString): Boolean;
+operator = (const s: AnsiString; constref ev: TFUIMouseEvent): Boolean;
implementation
// ////////////////////////////////////////////////////////////////////////// //
-procedure THMouseEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; end;
-function THMouseEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end;
-function THMouseEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end;
-function THMouseEvent.motion (): Boolean; inline; begin result := (kind = TKind.Motion); end;
-procedure THMouseEvent.eat (); inline; begin mEaten := true; end;
-procedure THMouseEvent.cancel (); inline; begin mCancelled := true; end;
-
-procedure THKeyEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; ch := #0; scan := 0; end;
-function THKeyEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end;
-function THKeyEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end;
-procedure THKeyEvent.eat (); inline; begin mEaten := true; end;
-procedure THKeyEvent.cancel (); inline; begin mCancelled := true; end;
-
-function THKeyEvent.isHot (c: AnsiChar): Boolean;
+procedure TFUIMouseEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; end;
+function TFUIMouseEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end;
+function TFUIMouseEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end;
+function TFUIMouseEvent.motion (): Boolean; inline; begin result := (kind = TKind.Motion); end;
+function TFUIMouseEvent.isAlive (): Boolean; inline; begin result := (not mEaten) and (not mCancelled); end;
+procedure TFUIMouseEvent.eat (); inline; begin mEaten := true; end;
+procedure TFUIMouseEvent.cancel (); inline; begin mCancelled := true; end;
+
+procedure TFUIKeyEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; ch := #0; scan := 0; end;
+function TFUIKeyEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end;
+function TFUIKeyEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end;
+function TFUIKeyEvent.isAlive (): Boolean; inline; begin result := (not mEaten) and (not mCancelled); end;
+procedure TFUIKeyEvent.eat (); inline; begin mEaten := true; end;
+procedure TFUIKeyEvent.cancel (); inline; begin mCancelled := true; end;
+
+function TFUIKeyEvent.isHot (c: AnsiChar): Boolean;
begin
if (c = #0) or (scan = 0) or (scan = $FFFF) then begin result := false; exit; end;
case scan of
if (Length(s)-pos >= 1) and (s[pos+1] = '-') then
begin
case s[pos] of
- 'C', 'c': begin if (kmods = 255) then kmods := 0; kmods := kmods or THKeyEvent.ModCtrl; Inc(pos, 2); continue; end;
- 'M', 'm': begin if (kmods = 255) then kmods := 0; kmods := kmods or THKeyEvent.ModAlt; Inc(pos, 2); continue; end;
- 'S', 's': begin if (kmods = 255) then kmods := 0; kmods := kmods or THKeyEvent.ModShift; Inc(pos, 2); continue; end;
+ 'C', 'c': begin if (kmods = 255) then kmods := 0; kmods := kmods or TFUIKeyEvent.ModCtrl; Inc(pos, 2); continue; end;
+ 'M', 'm': begin if (kmods = 255) then kmods := 0; kmods := kmods or TFUIKeyEvent.ModAlt; Inc(pos, 2); continue; end;
+ 'S', 's': begin if (kmods = 255) then kmods := 0; kmods := kmods or TFUIKeyEvent.ModShift; Inc(pos, 2); continue; end;
end;
break;
end;
if (Length(s)-pos >= 3) and (s[pos+3] = '-') and ((s[pos+1] = 'M') or (s[pos+1] = 'm')) and ((s[pos+2] = 'B') or (s[pos+2] = 'b')) then
begin
case s[pos] of
- 'L', 'l': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or THMouseEvent.Left; Inc(pos, 4); continue; end;
- 'R', 'r': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or THMouseEvent.Right; Inc(pos, 4); continue; end;
- 'M', 'm': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or THMouseEvent.Middle; Inc(pos, 4); continue; end;
+ 'L', 'l': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or TFUIMouseEvent.Left; Inc(pos, 4); continue; end;
+ 'R', 'r': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or TFUIMouseEvent.Right; Inc(pos, 4); continue; end;
+ 'M', 'm': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or TFUIMouseEvent.Middle; Inc(pos, 4); continue; end;
end;
break;
end;
end;
-operator = (constref ev: THKeyEvent; const s: AnsiString): Boolean;
+operator = (constref ev: TFUIKeyEvent; const s: AnsiString): Boolean;
var
f: Integer;
kmods: Byte = 255;
end;
-operator = (const s: AnsiString; constref ev: THKeyEvent): Boolean;
+operator = (const s: AnsiString; constref ev: TFUIKeyEvent): Boolean;
begin
result := (ev = s);
end;
-operator = (constref ev: THMouseEvent; const s: AnsiString): Boolean;
+operator = (constref ev: TFUIMouseEvent; const s: AnsiString): Boolean;
var
kmods: Byte = 255;
mbuts: Byte = 255;
end;
kname := parseModKeys(s, kmods, mbuts);
- if strEquCI(kname, 'LMB') then but := THMouseEvent.Left
- else if strEquCI(kname, 'RMB') then but := THMouseEvent.Right
- else if strEquCI(kname, 'MMB') then but := THMouseEvent.Middle
- else if strEquCI(kname, 'WheelUp') or strEquCI(kname, 'WUP') then but := THMouseEvent.WheelUp
- else if strEquCI(kname, 'WheelDown') or strEquCI(kname, 'WDN') or strEquCI(kname, 'WDOWN') then but := THMouseEvent.WheelDown
+ if strEquCI(kname, 'LMB') then but := TFUIMouseEvent.Left
+ else if strEquCI(kname, 'RMB') then but := TFUIMouseEvent.Right
+ else if strEquCI(kname, 'MMB') then but := TFUIMouseEvent.Middle
+ else if strEquCI(kname, 'WheelUp') or strEquCI(kname, 'WUP') then but := TFUIMouseEvent.WheelUp
+ else if strEquCI(kname, 'WheelDown') or strEquCI(kname, 'WDN') or strEquCI(kname, 'WDOWN') then but := TFUIMouseEvent.WheelDown
else if strEquCI(kname, 'None') then but := 0
else exit;
end;
-operator = (const s: AnsiString; constref ev: THMouseEvent): Boolean;
+operator = (const s: AnsiString; constref ev: TFUIMouseEvent): Boolean;
begin
result := (ev = s);
end;
procedure fuiResetKMState (sendEvents: Boolean=true);
var
mask: Word;
- mev: THMouseEvent;
- kev: THKeyEvent;
+ mev: TFUIMouseEvent;
+ kev: TFUIKeyEvent;
begin
// generate mouse release events
if (curButState <> 0) then
kev.intrInit();
kev.kind := kev.TKind.Release;
case mask of
- THKeyEvent.ModCtrl: begin kev.scan := SDL_SCANCODE_LCTRL; {kev.sym := SDLK_LCTRL;}{arbitrary} end;
- THKeyEvent.ModAlt: begin kev.scan := SDL_SCANCODE_LALT; {kev.sym := SDLK_LALT;}{arbitrary} end;
- THKeyEvent.ModShift: begin kev.scan := SDL_SCANCODE_LSHIFT; {kev.sym := SDLK_LSHIFT;}{arbitrary} end;
- THKeyEvent.ModHyper: begin kev.scan := SDL_SCANCODE_LGUI; {kev.sym := SDLK_LGUI;}{arbitrary} end;
+ TFUIKeyEvent.ModCtrl: begin kev.scan := SDL_SCANCODE_LCTRL; {kev.sym := SDLK_LCTRL;}{arbitrary} end;
+ TFUIKeyEvent.ModAlt: begin kev.scan := SDL_SCANCODE_LALT; {kev.sym := SDLK_LALT;}{arbitrary} end;
+ TFUIKeyEvent.ModShift: begin kev.scan := SDL_SCANCODE_LSHIFT; {kev.sym := SDLK_LSHIFT;}{arbitrary} end;
+ TFUIKeyEvent.ModHyper: begin kev.scan := SDL_SCANCODE_LGUI; {kev.sym := SDLK_LGUI;}{arbitrary} end;
else assert(false);
end;
kev.x := curMsX;
index 33a4664d004d493228af37ce69701a4e04c47cee..71e7993674f2a639278b6cbbe55e720a4a658ba5 100644 (file)
// ////////////////////////////////////////////////////////////////////////// //
function fuiOnSDLEvent (var ev: TSDL_Event): Boolean;
var
- mev: THMouseEvent;
- kev: THKeyEvent;
+ mev: TFUIMouseEvent;
+ kev: TFUIKeyEvent;
uc: UnicodeChar;
keychr: Word;
begin
result := 0;
case b of
- SDL_BUTTON_LEFT: result := result or THMouseEvent.Left;
- SDL_BUTTON_MIDDLE: result := result or THMouseEvent.Middle;
- SDL_BUTTON_RIGHT: result := result or THMouseEvent.Right;
+ SDL_BUTTON_LEFT: result := result or TFUIMouseEvent.Left;
+ SDL_BUTTON_MIDDLE: result := result or TFUIMouseEvent.Middle;
+ SDL_BUTTON_RIGHT: result := result or TFUIMouseEvent.Right;
end;
end;
// fix left/right modifiers
FillChar(kev, sizeof(kev), 0);
kev.intrInit();
- if (ev.type_ = SDL_KEYDOWN) then kev.kind := THKeyEvent.TKind.Press else kev.kind := THKeyEvent.TKind.Release;
+ if (ev.type_ = SDL_KEYDOWN) then kev.kind := TFUIKeyEvent.TKind.Press else kev.kind := TFUIKeyEvent.TKind.Release;
kev.scan := ev.key.keysym.scancode;
//kev.sym := ev.key.keysym.sym;
kev.kstate := fuiModState;
case kev.scan of
- SDL_SCANCODE_LCTRL: if (kev.press) then fuiSetModState(fuiModState or THKeyEvent.ModCtrl) else fuiSetModState(fuiModState and (not THKeyEvent.ModCtrl));
- SDL_SCANCODE_LALT: if (kev.press) then fuiSetModState(fuiModState or THKeyEvent.ModAlt) else fuiSetModState(fuiModState and (not THKeyEvent.ModAlt));
- SDL_SCANCODE_LSHIFT: if (kev.press) then fuiSetModState(fuiModState or THKeyEvent.ModShift) else fuiSetModState(fuiModState and (not THKeyEvent.ModShift));
+ SDL_SCANCODE_LCTRL: if (kev.press) then fuiSetModState(fuiModState or TFUIKeyEvent.ModCtrl) else fuiSetModState(fuiModState and (not TFUIKeyEvent.ModCtrl));
+ SDL_SCANCODE_LALT: if (kev.press) then fuiSetModState(fuiModState or TFUIKeyEvent.ModAlt) else fuiSetModState(fuiModState and (not TFUIKeyEvent.ModAlt));
+ SDL_SCANCODE_LSHIFT: if (kev.press) then fuiSetModState(fuiModState or TFUIKeyEvent.ModShift) else fuiSetModState(fuiModState and (not TFUIKeyEvent.ModShift));
end;
if assigned(evKeyCB) then
begin
FillChar(mev, sizeof(mev), 0);
mev.intrInit();
- if (ev.type_ = SDL_MOUSEBUTTONDOWN) then mev.kind := THMouseEvent.TKind.Press else mev.kind := THMouseEvent.TKind.Release;
+ if (ev.type_ = SDL_MOUSEBUTTONDOWN) then mev.kind := TFUIMouseEvent.TKind.Press else mev.kind := TFUIMouseEvent.TKind.Release;
mev.dx := ev.button.x-fuiMouseX;
mev.dy := ev.button.y-fuiMouseY;
fuiSetMouseX(ev.button.x);
begin
FillChar(mev, sizeof(mev), 0);
mev.intrInit();
- mev.kind := THMouseEvent.TKind.Press;
+ mev.kind := TFUIMouseEvent.TKind.Press;
mev.dx := 0;
mev.dy := ev.wheel.y;
- if (ev.wheel.y < 0) then mev.but := THMouseEvent.WheelUp else mev.but := THMouseEvent.WheelDown;
+ if (ev.wheel.y < 0) then mev.but := TFUIMouseEvent.WheelUp else mev.but := TFUIMouseEvent.WheelDown;
mev.x := fuiMouseX;
mev.y := fuiMouseY;
mev.bstate := fuiButState;
begin
FillChar(mev, sizeof(mev), 0);
mev.intrInit();
- mev.kind := THMouseEvent.TKind.Motion;
+ mev.kind := TFUIMouseEvent.TKind.Motion;
mev.dx := ev.button.x-fuiMouseX;
mev.dy := ev.button.y-fuiMouseY;
fuiSetMouseX(ev.button.x);
end;
SDL_TEXTINPUT:
- if ((fuiModState and (not THKeyEvent.ModShift)) = 0) then
+ if ((fuiModState and (not TFUIKeyEvent.ModShift)) = 0) then
begin
Utf8ToUnicode(@uc, PChar(ev.text.text), 1);
keychr := Word(uc);
begin
FillChar(kev, sizeof(kev), 0);
kev.intrInit();
- kev.kind := THKeyEvent.TKind.Press;
+ kev.kind := TFUIKeyEvent.TKind.Press;
kev.scan := 0;
kev.ch := AnsiChar(keychr);
kev.x := fuiMouseX;
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 5f1cb3e71055523efb7483cecd4748dbce5a54e8..0b5c00de044b53516432b702412a73a6e5d6f48d 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
procedure g_Holmes_Draw ();
procedure g_Holmes_DrawUI ();
-procedure g_Holmes_MouseEvent (var ev: THMouseEvent);
-procedure g_Holmes_KeyEvent (var ev: THKeyEvent);
+procedure g_Holmes_MouseEvent (var ev: TFUIMouseEvent);
+procedure g_Holmes_KeyEvent (var ev: TFUIKeyEvent);
// hooks for player
procedure g_Holmes_plrViewPos (viewPortX, viewPortY: Integer);
@@ -543,11 +543,11 @@ function pmsCurMapX (): Integer; inline; begin result := round(msX/g_dbg_scale)+
function pmsCurMapY (): Integer; inline; begin result := round(msY/g_dbg_scale)+vpy; end;
-procedure plrDebugMouse (var ev: THMouseEvent);
+procedure plrDebugMouse (var ev: TFUIMouseEvent);
begin
//e_WriteLog(Format('mouse: x=%d; y=%d; but=%d; bstate=%d', [msx, msy, but, bstate]), MSG_NOTIFY);
if (gPlayer1 = nil) or not vpSet then exit;
- //if (ev.kind <> THMouseEvent.Press) then exit;
+ //if (ev.kind <> TFUIMouseEvent.Press) then exit;
//e_WriteLog(Format('mev: %d', [Integer(ev.kind)]), MSG_NOTIFY);
msbindExecute(ev);
end;
// ////////////////////////////////////////////////////////////////////////// //
-procedure g_Holmes_MouseEvent (var ev: THMouseEvent);
+procedure g_Holmes_MouseEvent (var ev: TFUIMouseEvent);
var
- he: THMouseEvent;
+ he: TFUIMouseEvent;
begin
if g_Game_IsNet then exit;
if not g_holmes_enabled then exit;
he.x := he.x;
he.y := he.y;
uiMouseEvent(he);
- if (not he.eaten) then plrDebugMouse(he);
+ if (he.alive) then plrDebugMouse(he);
ev.eat();
end;
// ////////////////////////////////////////////////////////////////////////// //
-procedure g_Holmes_KeyEvent (var ev: THKeyEvent);
+procedure g_Holmes_KeyEvent (var ev: TFUIKeyEvent);
var
doeat: Boolean = false;
{$IF DEFINED(D2F_DEBUG)}
end;
uiKeyEvent(ev);
- if (ev.eaten) then exit;
+ if (not ev.alive) then exit;
if keybindExecute(ev) then begin ev.eat(); exit; end;
// press
if (ev.press) then
{$IF DEFINED(D2F_DEBUG)}
// C-UP, C-DOWN, C-LEFT, C-RIGHT: trace 10 pixels from cursor in the respective direction
if ((ev.scan = SDL_SCANCODE_UP) or (ev.scan = SDL_SCANCODE_DOWN) or (ev.scan = SDL_SCANCODE_LEFT) or (ev.scan = SDL_SCANCODE_RIGHT)) and
- ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
+ ((ev.kstate and TFUIKeyEvent.ModCtrl) <> 0) then
begin
ev.eat();
dx := pmsCurMapX;
end;
-procedure onMouseEvent (var ev: THMouseEvent);
+procedure onMouseEvent (var ev: TFUIMouseEvent);
begin
if not g_holmes_enabled then exit;
if g_holmes_imfunctional then exit;
g_Holmes_MouseEvent(ev);
end;
-procedure onKeyEvent (var ev: THKeyEvent);
+procedure onKeyEvent (var ev: TFUIKeyEvent);
begin
if not g_holmes_enabled then exit;
if g_holmes_imfunctional then exit;
index e76b7f2918268195a3ea72b463573828fee3ac66..dfa49305db8bcee42699e72c38d2b42ea36d5848 100644 (file)
end;
-function keybindExecute (var ev: THKeyEvent): Boolean;
+function keybindExecute (var ev: TFUIKeyEvent): Boolean;
var
f: Integer;
begin
end;
-function msbindExecute (var ev: THMouseEvent): Boolean;
+function msbindExecute (var ev: TFUIMouseEvent): Boolean;
var
f: Integer;
begin