mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 12:29:29 +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 = class
|
||||
private
|
||||
_lastCursor: NSCursor;
|
||||
private
|
||||
procedure DoSetCursorOnActive( data:IntPtr );
|
||||
public
|
||||
procedure SetNewCursor( newCursor:TCocoaCursor );
|
||||
public
|
||||
class procedure SetCursorOnActive;
|
||||
class procedure SetCurrentControlCursor;
|
||||
@ -368,8 +372,21 @@ begin
|
||||
SetCurrentControlCursor;
|
||||
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;
|
||||
begin
|
||||
CursorHelper._lastCursor:= nil;
|
||||
Application.QueueAsyncCall( @CursorHelper.DoSetCursorOnActive, 0 );
|
||||
end;
|
||||
|
||||
@ -1843,7 +1860,7 @@ begin
|
||||
if control<>AWinControl then
|
||||
exit;
|
||||
|
||||
TCocoaCursor(ACursor).SetCursor;
|
||||
CursorHelper.SetNewCursor( TCocoaCursor(ACursor) );
|
||||
end;
|
||||
|
||||
type
|
||||
|
Loading…
Reference in New Issue
Block a user