mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 12:02:48 +02:00
cocoa: adding the code to compensate for Cocoa feature, of mouseUp even not being called for Windows title
git-svn-id: trunk@56891 -
This commit is contained in:
parent
d6118dcce8
commit
dd5f953aae
@ -364,6 +364,7 @@ type
|
|||||||
TCocoaWindow = objcclass(NSWindow, NSWindowDelegateProtocol)
|
TCocoaWindow = objcclass(NSWindow, NSWindowDelegateProtocol)
|
||||||
protected
|
protected
|
||||||
fieldEditor: TCocoaFieldEditor;
|
fieldEditor: TCocoaFieldEditor;
|
||||||
|
firedMouseEvent: Boolean;
|
||||||
function windowShouldClose(sender : id): LongBool; message 'windowShouldClose:';
|
function windowShouldClose(sender : id): LongBool; message 'windowShouldClose:';
|
||||||
function windowWillReturnFieldEditor_toObject(sender: NSWindow; client: id): id; message 'windowWillReturnFieldEditor:toObject:';
|
function windowWillReturnFieldEditor_toObject(sender: NSWindow; client: id): id; message 'windowWillReturnFieldEditor:toObject:';
|
||||||
procedure windowWillClose(notification: NSNotification); message 'windowWillClose:';
|
procedure windowWillClose(notification: NSNotification); message 'windowWillClose:';
|
||||||
@ -1401,6 +1402,7 @@ end;
|
|||||||
|
|
||||||
procedure TCocoaWindow.mouseUp(event: NSEvent);
|
procedure TCocoaWindow.mouseUp(event: NSEvent);
|
||||||
begin
|
begin
|
||||||
|
firedMouseEvent:=true;
|
||||||
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
|
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
|
||||||
inherited mouseUp(event);
|
inherited mouseUp(event);
|
||||||
end;
|
end;
|
||||||
@ -1478,6 +1480,11 @@ var
|
|||||||
LP: LParam;
|
LP: LParam;
|
||||||
ResultCode: NSNumber;
|
ResultCode: NSNumber;
|
||||||
Obj: NSObject;
|
Obj: NSObject;
|
||||||
|
|
||||||
|
Epos: NSPoint;
|
||||||
|
cr : NSRect;
|
||||||
|
fr : NSRect;
|
||||||
|
trackEvent: Boolean;
|
||||||
begin
|
begin
|
||||||
if event.type_ = NSApplicationDefined then
|
if event.type_ = NSApplicationDefined then
|
||||||
begin
|
begin
|
||||||
@ -1501,6 +1508,32 @@ begin
|
|||||||
//ResultCode.release; // will be auto-released
|
//ResultCode.release; // will be auto-released
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if event.type_ = NSLeftMouseUp then
|
||||||
|
// This code is introduced here for an odd cocoa feature.
|
||||||
|
// mouseUp is not fired, if pressed on Window's title.
|
||||||
|
// (even though mouseDown, mouseMove and mouseDragged are fired)
|
||||||
|
// (there are some information in the internet, that mouseDown is not firing as well)
|
||||||
|
// (however this is not true for macOS 10.12)
|
||||||
|
// The logic below is as following. If mouseUp event arrived
|
||||||
|
// and mouse position is on the title of the form.
|
||||||
|
// then try to process the event. If event was not processed, call mouseUp()
|
||||||
|
// specifically.
|
||||||
|
begin
|
||||||
|
Epos:=event.locationInWindow;
|
||||||
|
fr := frame;
|
||||||
|
fr.origin.x:=0;
|
||||||
|
fr.origin.y:=0;
|
||||||
|
cr := contentRectForFrameRect(fr);
|
||||||
|
if NSPointInRect(Epos, fr) and not NSPointInRect(Epos, cr) then
|
||||||
|
begin
|
||||||
|
firedMouseEvent := false;
|
||||||
|
inherited sendEvent(event);
|
||||||
|
if not firedMouseEvent then mouseUp(event);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
inherited sendEvent(event);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
inherited sendEvent(event);
|
inherited sendEvent(event);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user