mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 12:39:40 +02:00
keep LM_SETFOCUS/LM_KILLFOCUS/LM_DESTROY consistent with Win32
This commit is contained in:
commit
7b75e8ba5d
@ -170,6 +170,9 @@ type
|
||||
|
||||
procedure DoSetMainMenu(AMenu: NSMenu; ALCLMenu: TMenu);
|
||||
public
|
||||
KeyWindow: NSWindow;
|
||||
KillingFocus: Boolean;
|
||||
|
||||
// modal session
|
||||
Modals : TList;
|
||||
ModalCounter: Integer; // the cheapest way to determine if modal window was called
|
||||
|
@ -2148,8 +2148,15 @@ var
|
||||
lclobj : TObject;
|
||||
begin
|
||||
Result := 0;
|
||||
if KillingFocus then
|
||||
Exit;
|
||||
|
||||
win := NSApp.keyWindow;
|
||||
if not Assigned(win) then Exit;
|
||||
if not Assigned(win) then
|
||||
win := CocoaWidgetSet.KeyWindow;
|
||||
if not Assigned(win) then
|
||||
Exit;
|
||||
|
||||
// assuming that that the content view of Window
|
||||
// is the focused handle and return it, by default
|
||||
Result := HWND(win.contentView);
|
||||
|
@ -1376,7 +1376,12 @@ end;
|
||||
procedure TLCLCommonCallback.ResignFirstResponder;
|
||||
begin
|
||||
if not Assigned(Target) then Exit;
|
||||
LCLSendKillFocusMsg(Target);
|
||||
CocoaWidgetSet.KillingFocus:= true;
|
||||
try
|
||||
LCLSendKillFocusMsg(Target);
|
||||
finally
|
||||
CocoaWidgetSet.KillingFocus:= false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLCLCommonCallback.DidBecomeKeyNotification;
|
||||
@ -1621,6 +1626,12 @@ begin
|
||||
CocoaWidgetSet.ReleaseCapture;
|
||||
|
||||
obj := NSObject(AWinControl.Handle);
|
||||
Callback := obj.lclGetCallback;
|
||||
|
||||
if AWinControl.Focused and Assigned(Callback) then
|
||||
Callback.ResignFirstResponder; // dont' call LCLSendKillFocusMsg
|
||||
LCLSendDestroyMsg( AWinControl );
|
||||
|
||||
if obj.isKindOfClass_(NSView) then
|
||||
begin
|
||||
// no need to "retain" prior to "removeFromSuperview"
|
||||
@ -1633,7 +1644,6 @@ begin
|
||||
NSWindow(obj).close;
|
||||
|
||||
// destroy the callback
|
||||
Callback := obj.lclGetCallback;
|
||||
if Assigned(Callback) then
|
||||
begin
|
||||
if Callback.HasCaret then DestroyCaret(nil);
|
||||
|
@ -348,7 +348,10 @@ procedure TLCLWindowCallback.Activate;
|
||||
var
|
||||
ACustForm: TCustomForm;
|
||||
isDesign: Boolean;
|
||||
focusedCb: ICommonCallback;
|
||||
begin
|
||||
CocoaWidgetSet.KeyWindow:= window;
|
||||
|
||||
if not IsActivating then
|
||||
begin
|
||||
IsActivating:=True;
|
||||
@ -379,7 +382,9 @@ begin
|
||||
end;
|
||||
|
||||
LCLSendActivateMsg(Target, WA_ACTIVE, false);
|
||||
LCLSendSetFocusMsg(Target);
|
||||
focusedCb := window.firstResponder.lclGetCallback;
|
||||
if Assigned(focusedCb) then
|
||||
focusedCb.BecomeFirstResponder;
|
||||
// The only way to update Forms.ActiveCustomForm for the main form
|
||||
// is calling TCustomForm.SetFocusedControl, see bug 31056
|
||||
ACustForm.SetFocusedControl(ACustForm.ActiveControl);
|
||||
@ -392,9 +397,17 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLCLWindowCallback.Deactivate;
|
||||
var
|
||||
focusedCb: ICommonCallback;
|
||||
begin
|
||||
CocoaWidgetSet.KeyWindow:= nil;
|
||||
|
||||
focusedCb:= window.firstResponder.lclGetCallback;
|
||||
if Assigned(focusedCb) then begin
|
||||
if not (csDestroying in TComponent(focusedCb.GetTarget).ComponentState) then
|
||||
focusedCb.ResignFirstResponder;
|
||||
end;
|
||||
LCLSendActivateMsg(Target, WA_INACTIVE, false);
|
||||
LCLSendKillFocusMsg(Target);
|
||||
end;
|
||||
|
||||
procedure TLCLWindowCallback.CloseQuery(var CanClose: Boolean);
|
||||
|
Loading…
Reference in New Issue
Block a user