Merge pull request #4181 from bengotow/scroll-touch-events
Extend NativeWindow to track touch-based scroll events on OS X
This commit is contained in:
commit
059d97e1aa
7 changed files with 47 additions and 0 deletions
|
@ -499,10 +499,32 @@ NativeWindowMac::NativeWindowMac(
|
|||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
||||
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
||||
BOOL __block down = NO;
|
||||
event_monitor_.reset([[NSEvent
|
||||
addLocalMonitorForEventsMatchingMask:NSScrollWheelMask
|
||||
handler:^NSEvent * _Nullable(NSEvent * event) {
|
||||
if ([[event window] windowNumber] != [window_ windowNumber])
|
||||
return event;
|
||||
|
||||
if (!web_contents)
|
||||
return event;
|
||||
|
||||
if (!down && (([event phase] == NSEventPhaseMayBegin) || ([event phase] == NSEventPhaseBegan))) {
|
||||
this->NotifyWindowScrollTouchBegin();
|
||||
down = YES;
|
||||
}
|
||||
if (down && (([event phase] == NSEventPhaseEnded) || ([event phase] == NSEventPhaseCancelled))) {
|
||||
this->NotifyWindowScrollTouchEnd();
|
||||
down = NO;
|
||||
}
|
||||
return event;
|
||||
}] retain]);
|
||||
|
||||
InstallView();
|
||||
}
|
||||
|
||||
NativeWindowMac::~NativeWindowMac() {
|
||||
[NSEvent removeMonitor: event_monitor_.get()];
|
||||
Observe(nullptr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue