X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fflexui%2Ffui_ctls.pas;h=12f710c21bbc3aae1845bc6b1c68bc8d8e5fd79e;hb=555f5293fc0e11c8965e6d13c639e545b0228eb9;hp=38f17fd0c928a893b7bbb1bc75662ea46da8b9ef;hpb=08b53e05935bfc8f5c8e6c18754fd3768917aa77;p=d2df-sdl.git diff --git a/src/flexui/fui_ctls.pas b/src/flexui/fui_ctls.pas index 38f17fd..12f710c 100644 --- a/src/flexui/fui_ctls.pas +++ b/src/flexui/fui_ctls.pas @@ -3,8 +3,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -587,6 +586,7 @@ uses var + uiInsideDispatcher: Boolean = false; uiTopList: array of TUIControl = nil; uiGrabCtl: TUIControl = nil; @@ -850,9 +850,12 @@ var var svx, svy, svdx, svdy: Integer; svscale: Single; + odp: Boolean; begin processKills(); if (not evt.alive) then exit; + odp := uiInsideDispatcher; + uiInsideDispatcher := true; //writeln('ENTER: FUI DISPATCH'); ev := evt; // normalize mouse coordinates @@ -878,6 +881,7 @@ begin dispatchTo(uiGetFocusedCtl); end; finally + uiInsideDispatcher := odp; if (ev.x = svx) and (ev.y = svy) and (ev.dx = svdx) and (ev.dy = svdy) then begin // due to possible precision loss @@ -945,7 +949,12 @@ end; function uiGetFocusedCtl (): TUIControl; begin - if (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then result := uiTopList[High(uiTopList)].mFocused else result := nil; + result := nil; + if (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then + begin + result := uiTopList[High(uiTopList)].mFocused; + if (result = nil) then result := uiTopList[High(uiTopList)]; + end; end; @@ -1067,7 +1076,27 @@ end; destructor TUIControl.Destroy (); var f, c: Integer; + doActivateOtherWin: Boolean = false; begin + if (uiInsideDispatcher) then raise Exception.Create('FlexUI: cannot destroy objects in event dispatcher'); + if (uiGrabCtl = self) then uiGrabCtl := nil; + // just in case, check if this is top-level shit + for f := 0 to High(uiTopList) do + begin + if (uiTopList[f] = self) then + begin + if (uiGrabCtl <> nil) and (isMyChild(uiGrabCtl)) then uiGrabCtl := nil; + for c := f+1 to High(uiTopList) do uiTopList[c-1] := uiTopList[c]; + SetLength(uiTopList, Length(uiTopList)-1); + doActivateOtherWin := true; + break; + end; + end; + if (doActivateOtherWin) and (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then + begin + uiTopList[High(uiTopList)].activated(); + end; + // other checks if (mParent <> nil) then begin setFocused(false);