cocoa: providing support for tracking event. (forwarding dragged events to LCL as mousemove)

git-svn-id: trunk@58599 -
This commit is contained in:
dmitry 2018-07-23 02:25:54 +00:00
parent 526e755e0e
commit d8f5c59da5
3 changed files with 34 additions and 0 deletions

View File

@ -83,6 +83,7 @@ type
function isRunning: Boolean; override;
procedure run; override;
procedure sendEvent(theEvent: NSEvent); override;
function nextEventMatchingMask_untilDate_inMode_dequeue(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: Boolean): NSEvent; override;
end;
TCocoaPasteboardsRef = record
@ -397,6 +398,23 @@ begin
inherited sendEvent(theEvent);
end;
function TCocoaApplication.nextEventMatchingMask_untilDate_inMode_dequeue(
mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: Boolean
): NSEvent;
var
cb : ICommonCallback;
begin
Result:=inherited nextEventMatchingMask_untilDate_inMode_dequeue(mask,
expiration, mode, deqFlag);
if Assigned(Result)
and ((mode = NSEventTrackingRunLoopMode) or mode.isEqualToString(NSEventTrackingRunLoopMode))
and Assigned(TrackedControl)
then begin
cb := TrackedControl.lclGetCallback;
if Assigned(cb) then cb.MouseMove(Result);
end;
end;
// the implementation of the utility methods
{$I cocoaobject.inc}
// the implementation of the winapi compatibility methods

View File

@ -320,6 +320,10 @@ const
NSTextAlignmentJustified = 3;
NSTextAlignmentNatural = 4;
var
// todo: this should be a threadvar
TrackedControl : NSObject = nil;
implementation
uses CocoaInt;

View File

@ -859,6 +859,18 @@ begin
end;
//debugln('MouseUpDownEvent:'+DbgS(Msg.Msg)+' Target='+Target.name+);
if not Result then
//Result := Result or (BlockCocoaUpDown and not AOverrideBlock);
case lEventType of
NSLeftMouseDown,
NSRightMouseDown,
NSOtherMouseDown:
TrackedControl := Owner;
NSLeftMouseUp,
NSRightMouseUp,
NSOtherMouseUp:
if TrackedControl = Owner then TrackedControl := nil;
end;
end;
function TLCLCommonCallback.MouseMove(Event: NSEvent): Boolean;