mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 20:30:41 +02:00
cocoa: update to applicaiton event processing to forward mouseMove events to non keywindows under the cursor
git-svn-id: trunk@59001 -
This commit is contained in:
parent
1871fb6f58
commit
e4ad7a78b2
@ -361,6 +361,47 @@ begin
|
||||
aloop();
|
||||
end;
|
||||
|
||||
procedure ForwardMouseMove(app: NSApplication; theEvent: NSEvent);
|
||||
var
|
||||
w : NSWindow;
|
||||
kw : NSWindow;
|
||||
ev : NSEvent;
|
||||
p : NSPoint;
|
||||
wfr : NSRect;
|
||||
begin
|
||||
kw := app.keyWindow;
|
||||
|
||||
// mouse move was consumed by the focused window
|
||||
if Assigned(kw) and NSPointInRect( theEvent.mouseLocation, kw.frame) then
|
||||
Exit;
|
||||
|
||||
for w in app.windows do
|
||||
begin
|
||||
if w = kw then Continue;
|
||||
if not w.isVisible then Continue;
|
||||
// todo: check for enabled windows? modal windows?
|
||||
|
||||
wfr := w.frame;
|
||||
if not NSPointInRect( theEvent.mouseLocation, wfr) then Continue;
|
||||
|
||||
p := theEvent.mouseLocation;
|
||||
p.x := p.x - w.frame.origin.x;
|
||||
p.y := p.y - w.frame.origin.y;
|
||||
ev := NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure(
|
||||
theEvent.type_,
|
||||
p,
|
||||
theEvent.modifierFlags,
|
||||
theEvent.timestamp,
|
||||
w.windowNumber,
|
||||
theEvent.context,
|
||||
theEvent.eventNumber,
|
||||
theEvent.clickCount,
|
||||
theEvent.pressure
|
||||
);
|
||||
w.sendEvent(ev);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaApplication.sendEvent(theEvent: NSEvent);
|
||||
begin
|
||||
// https://stackoverflow.com/questions/4001565/missing-keyup-events-on-meaningful-key-combinations-e-g-select-till-beginning
|
||||
@ -369,6 +410,8 @@ begin
|
||||
then
|
||||
self.keyWindow.sendEvent(theEvent);
|
||||
inherited sendEvent(theEvent);
|
||||
|
||||
if (theEvent.type_ = NSMouseMoved) then ForwardMouseMove(Self, theEvent);
|
||||
end;
|
||||
|
||||
function isMouseMoveEvent(tp: NSEventType): Boolean; inline;
|
||||
|
@ -806,13 +806,9 @@ end;
|
||||
|
||||
procedure TCocoaWindow.mouseMoved(event: NSEvent);
|
||||
begin
|
||||
if (Self = NSApplication.sharedApplication.keyWindow) then
|
||||
// no need to call "callback".
|
||||
// mouseMove would be called on the WindowContent
|
||||
inherited mouseMoved(event)
|
||||
else
|
||||
if not Assigned(callback) or not callback.MouseMove(event) then
|
||||
inherited mouseMoved(event);
|
||||
// no need to call for callback or anything, because WindowContent
|
||||
// will take care of it anyway
|
||||
inherited mouseMoved(event);
|
||||
end;
|
||||
|
||||
procedure TCocoaWindow.scrollWheel(event: NSEvent);
|
||||
|
Loading…
Reference in New Issue
Block a user