mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-30 18:01:53 +01:00 
			
		
		
		
	Cocoa: Cursor: Improve support for Window/Application switching
This commit is contained in:
		
							parent
							
								
									da41c019a6
								
							
						
					
					
						commit
						cdbab01c2d
					
				| @ -27,7 +27,7 @@ uses | ||||
|   Types, Classes, SysUtils, | ||||
|   CGGeometry, | ||||
|   // Libs | ||||
|   MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects, | ||||
|   MacOSAll, CocoaAll, CocoaUtils, CocoaWScommon, | ||||
|   cocoa_extra, CocoaPrivate, CocoaTextEdits, CocoaScrollers, | ||||
|   // LCL | ||||
|   //Forms, | ||||
| @ -776,6 +776,8 @@ begin | ||||
|     and Assigned(contentView) | ||||
|     and (contentView.isKindOfClass(TCocoaWindowContent)) then | ||||
|     self.makeFirstResponder( TCocoaWindowContent(contentView).documentView ); | ||||
| 
 | ||||
|   CursorHelper.SetCursorOnActive; | ||||
| end; | ||||
| 
 | ||||
| procedure TCocoaWindow.windowDidResignKey(notification: NSNotification); | ||||
|  | ||||
| @ -12,7 +12,7 @@ uses | ||||
|   CGGeometry, CocoaAll, cocoa_extra, | ||||
|   Classes, Controls, SysUtils, | ||||
|   // | ||||
|   WSControls, LCLType, LMessages, LCLProc, Graphics, Forms, | ||||
|   WSControls, LCLType, LMessages, LCLProc, LCLIntf, Graphics, Forms, | ||||
|   CocoaPrivate, CocoaGDIObjects, CocoaCaret, CocoaUtils, LCLMessageGlue, | ||||
|   CocoaScrollers; | ||||
| 
 | ||||
| @ -20,7 +20,11 @@ type | ||||
|   { TCursorHelper } | ||||
| 
 | ||||
|   TCursorHelper = class | ||||
|   private | ||||
|     procedure CallSetCurrentControlCursor( data:IntPtr ); | ||||
|   public | ||||
|     class procedure SetCursorOnActive; | ||||
|     class procedure SetCurrentControlCursor; | ||||
|     class procedure SetScreenCursor; | ||||
|     class procedure SetScreenCursorWhenNotDefault; | ||||
|   end; | ||||
| @ -356,6 +360,30 @@ end; | ||||
| 
 | ||||
| { TCursorHelper } | ||||
| 
 | ||||
| procedure TCursorHelper.CallSetCurrentControlCursor( data:IntPtr ); | ||||
| begin | ||||
|   SetCurrentControlCursor; | ||||
| end; | ||||
| 
 | ||||
| class procedure TCursorHelper.SetCursorOnActive; | ||||
| begin | ||||
|   if Screen.Cursor<>crDefault then | ||||
|     SetScreenCursor | ||||
|   else | ||||
|     Application.QueueAsyncCall( @CursorHelper.CallSetCurrentControlCursor, 0 ); | ||||
| end; | ||||
| 
 | ||||
| class procedure TCursorHelper.SetCurrentControlCursor; | ||||
| var | ||||
|   P: TPoint; | ||||
|   control: TControl; | ||||
| begin | ||||
|   GetCursorPos(P); | ||||
|   control:= FindControlAtPosition(P, true);; | ||||
|   if Assigned(control) then | ||||
|     TCocoaCursor(Screen.Cursors[control.Cursor]).SetCursor; | ||||
| end; | ||||
| 
 | ||||
| class procedure TCursorHelper.SetScreenCursor; | ||||
| begin | ||||
|   TCocoaCursor(Screen.Cursors[Screen.Cursor]).SetCursor; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 rich2014
						rich2014