mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:19:23 +02:00
Cocoa: Cursor: compatible with system controls that change the cursor by themselves, such as NSTextField
This commit is contained in:
parent
c3e5af4513
commit
40e7dd7854
@ -20,8 +20,12 @@ type
|
|||||||
{ TCursorHelper }
|
{ TCursorHelper }
|
||||||
|
|
||||||
TCursorHelper = class
|
TCursorHelper = class
|
||||||
|
private
|
||||||
|
_lastCursor: NSCursor;
|
||||||
private
|
private
|
||||||
procedure DoSetCursorOnActive( data:IntPtr );
|
procedure DoSetCursorOnActive( data:IntPtr );
|
||||||
|
public
|
||||||
|
procedure SetNewCursor( newCursor:TCocoaCursor );
|
||||||
public
|
public
|
||||||
class procedure SetCursorOnActive;
|
class procedure SetCursorOnActive;
|
||||||
class procedure SetCurrentControlCursor;
|
class procedure SetCurrentControlCursor;
|
||||||
@ -368,8 +372,21 @@ begin
|
|||||||
SetCurrentControlCursor;
|
SetCurrentControlCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCursorHelper.SetNewCursor( newCursor:TCocoaCursor );
|
||||||
|
var
|
||||||
|
currentCursor: NSCursor;
|
||||||
|
begin
|
||||||
|
currentCursor:= NSCursor.currentCursor;
|
||||||
|
if (_lastCursor=nil) or (currentCursor=NSCursor.arrowCursor) or (currentCursor=_lastCursor) then
|
||||||
|
begin
|
||||||
|
newCursor.SetCursor;
|
||||||
|
_lastCursor:= newCursor.Cursor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TCursorHelper.SetCursorOnActive;
|
class procedure TCursorHelper.SetCursorOnActive;
|
||||||
begin
|
begin
|
||||||
|
CursorHelper._lastCursor:= nil;
|
||||||
Application.QueueAsyncCall( @CursorHelper.DoSetCursorOnActive, 0 );
|
Application.QueueAsyncCall( @CursorHelper.DoSetCursorOnActive, 0 );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1843,7 +1860,7 @@ begin
|
|||||||
if control<>AWinControl then
|
if control<>AWinControl then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
TCocoaCursor(ACursor).SetCursor;
|
CursorHelper.SetNewCursor( TCocoaCursor(ACursor) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
Loading…
Reference in New Issue
Block a user