mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
fixes browserview clicks and html dragging
This commit is contained in:
parent
6d80145876
commit
782aeb6b0a
1 changed files with 14 additions and 3 deletions
|
|
@ -9,12 +9,12 @@ static IMP g_originalMouseEvent;
|
|||
|
||||
static char kIsDraggableKey;
|
||||
static char kIsDraggingKey;
|
||||
static char kMouseEventTypeKey;
|
||||
|
||||
NSView* viewUnderneathPoint(NSView* self, NSPoint point) {
|
||||
NSView *contentView = self.window.contentView;
|
||||
NSArray *views = [contentView subviews];
|
||||
|
||||
for (NSView *v in views) {
|
||||
for (NSView *v in contentView.subviews.reverseObjectEnumerator) {
|
||||
if (v != self && ![v isKindOfClass:[NSVisualEffectView class]]) {
|
||||
NSPoint pointInView = [v convertPoint:point fromView:nil];
|
||||
if ([v hitTest:pointInView] && [v mouse:pointInView inRect:v.bounds]) {
|
||||
|
|
@ -46,13 +46,19 @@ void swizzledMouseEvent(id obj, SEL sel, NSEvent* theEvent) {
|
|||
&kIsDraggableKey);
|
||||
NSNumber* isDragging = objc_getAssociatedObject(obj,
|
||||
&kIsDraggingKey);
|
||||
NSNumber* previousEventType = objc_getAssociatedObject(obj,
|
||||
&kMouseEventTypeKey);
|
||||
|
||||
if ([theEvent type] == NSEventTypeLeftMouseDown && isDraggable.boolValue) {
|
||||
NSView* self = obj;
|
||||
[self.window performWindowDragWithEvent:theEvent];
|
||||
}
|
||||
|
||||
if ([theEvent type] == NSEventTypeLeftMouseDragged && isDraggable.boolValue) {
|
||||
BOOL isPreviousMouseDown =
|
||||
previousEventType.integerValue == NSEventTypeLeftMouseDown;
|
||||
BOOL isCurrentMouseDragged = [theEvent type] == NSEventTypeLeftMouseDragged;
|
||||
|
||||
if (isPreviousMouseDown && isCurrentMouseDragged && isDraggable.boolValue) {
|
||||
objc_setAssociatedObject(obj,
|
||||
&kIsDraggingKey,
|
||||
@(YES),
|
||||
|
|
@ -67,6 +73,11 @@ void swizzledMouseEvent(id obj, SEL sel, NSEvent* theEvent) {
|
|||
} else {
|
||||
((void(*) (id, SEL, NSEvent*))g_originalMouseEvent)(obj, sel, theEvent);
|
||||
}
|
||||
|
||||
objc_setAssociatedObject(obj,
|
||||
&kMouseEventTypeKey,
|
||||
@([theEvent type]),
|
||||
OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
}
|
||||
|
||||
void Setup(const Napi::CallbackInfo &info) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue