mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 02:40:24 +02:00
Cocoa: Cursor: completely refactored on LCL cursor infrastructure
This commit is contained in:
parent
d939016d4e
commit
7111681225
@ -311,9 +311,7 @@ type
|
||||
constructor CreateFromBitmap(const ABitmap: TCocoaBitmap; const hotSpot: NSPoint);
|
||||
constructor CreateFromCustomCursor(const ACursor: NSCursor);
|
||||
destructor Destroy; override;
|
||||
function Install: TCocoaCursor;
|
||||
procedure SetCursor;
|
||||
class procedure SetDefaultCursor;
|
||||
property Cursor: NSCursor read FCursor;
|
||||
property Standard: Boolean read FStandard;
|
||||
end;
|
||||
@ -1233,25 +1231,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TCocoaCursor.Install: TCocoaCursor;
|
||||
begin
|
||||
FCursor.push;
|
||||
// also request form cursors invalidation
|
||||
CocoaWidgetSet.NSApp.keyWindow.resetCursorRects;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCocoaCursor.SetCursor;
|
||||
begin
|
||||
FCursor.set_;
|
||||
FCursor.set_;
|
||||
end;
|
||||
|
||||
class procedure TCocoaCursor.SetDefaultCursor;
|
||||
begin
|
||||
NSCursor.arrowCursor.set_;
|
||||
end;
|
||||
|
||||
|
||||
{ TCocoaContext }
|
||||
|
||||
function TCocoaContext.CGContext: CGContextRef;
|
||||
|
@ -2519,8 +2519,9 @@ end;
|
||||
|
||||
function TCocoaWidgetSet.SetCursor(ACursor: HCURSOR): HCURSOR;
|
||||
begin
|
||||
if ACursor = 0 then Result := 0 else
|
||||
Result := HCURSOR(TCocoaCursor(ACursor).Install);
|
||||
if ACursor = 0 then ACursor:= Screen.Cursors[crDefault];
|
||||
TCocoaCursor(ACursor).SetCursor;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCocoaWidgetSet.SetCursorPos(X, Y: Integer): Boolean;
|
||||
|
@ -1798,17 +1798,24 @@ end;
|
||||
|
||||
class procedure TCocoaWSWinControl.SetCursor(const AWinControl: TWinControl;
|
||||
const ACursor: HCursor);
|
||||
var
|
||||
control: TControl;
|
||||
begin
|
||||
//debugln('SetCursor '+AWinControl.name+' '+dbgs(ACursor));
|
||||
if CocoaWidgetSet.CurrentCursor<>ACursor then
|
||||
begin
|
||||
CocoaWidgetSet.CurrentCursor:= ACursor;
|
||||
|
||||
if ACursor<>0 then
|
||||
TCocoaCursor(ACursor).SetCursor
|
||||
else
|
||||
TCocoaCursor.SetDefaultCursor;
|
||||
end;
|
||||
// screen cursor has higher priority than control cursor.
|
||||
if Screen.Cursor<>crDefault
|
||||
then exit;
|
||||
|
||||
// control cursor only need be set when mouse in AWinControl.
|
||||
// suppose there is a Button, which is to set a Cursor of a ListBox.
|
||||
// without the code here, it will be set to the Cursor of the ListBox
|
||||
// after clicking the Button.
|
||||
control:= Application.GetControlAtMouse;
|
||||
if control<>AWinControl then
|
||||
exit;
|
||||
|
||||
TCocoaCursor(ACursor).SetCursor;
|
||||
end;
|
||||
|
||||
type
|
||||
|
Loading…
Reference in New Issue
Block a user