mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-11 02:48:31 +02:00
Cocoa: simplify the code related to Focus
This commit is contained in:
parent
3542056197
commit
890ae752ca
@ -2551,35 +2551,20 @@ end;
|
||||
|
||||
function TCocoaWidgetSet.SetFocus(Handle: HWND): HWND;
|
||||
var
|
||||
Obj: NSObject;
|
||||
lView: NSView;
|
||||
cb: ICommonCallback;
|
||||
begin
|
||||
if Handle <> 0 then
|
||||
begin
|
||||
Result := GetFocus;
|
||||
if Result = Handle then
|
||||
Exit;
|
||||
Obj := NSObject(Handle);
|
||||
if Obj.isKindOfClass(NSWindow) then
|
||||
lView := NSObject(Handle).lclContentView;
|
||||
if Assigned(lView) and Assigned(lView.window) then
|
||||
begin
|
||||
NSWindow(Obj).makeKeyWindow;
|
||||
NSWindow(Obj).makeFirstResponder(nil);
|
||||
end
|
||||
else
|
||||
begin
|
||||
lView := obj.lclContentView;
|
||||
if lView <> nil then
|
||||
begin
|
||||
if lView.window <> nil then
|
||||
begin
|
||||
lView.window.makeKeyWindow;
|
||||
lView.window.makeFirstResponder(lView.lclContentView);
|
||||
end else
|
||||
Result := 0; // the view is on window, cannot set focus. Fail
|
||||
end else
|
||||
Result := 0;
|
||||
end;
|
||||
lView.window.makeKeyWindow;
|
||||
lView.window.makeFirstResponder(lView.lclContentView);
|
||||
end else
|
||||
Result := 0;
|
||||
end
|
||||
else
|
||||
Result := 0;
|
||||
|
@ -785,13 +785,6 @@ begin
|
||||
if Assigned(callback) then
|
||||
callback.Activate;
|
||||
|
||||
// LCL didn't change focus. TCocoaWindow should not keep the focus for itself
|
||||
// and it should pass it to it's content view
|
||||
if (firstResponder = self)
|
||||
and Assigned(contentView)
|
||||
and (contentView.isKindOfClass(TCocoaWindowContent)) then
|
||||
self.makeFirstResponder( TCocoaWindowContent(contentView).documentView );
|
||||
|
||||
performSelector_withObject_afterDelay( ObjCSelector('DoWindowDidBecomeKey'), nil, 0.1 );
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user