mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38: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 kIsDraggableKey;
|
||||||
static char kIsDraggingKey;
|
static char kIsDraggingKey;
|
||||||
|
static char kMouseEventTypeKey;
|
||||||
|
|
||||||
NSView* viewUnderneathPoint(NSView* self, NSPoint point) {
|
NSView* viewUnderneathPoint(NSView* self, NSPoint point) {
|
||||||
NSView *contentView = self.window.contentView;
|
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]]) {
|
if (v != self && ![v isKindOfClass:[NSVisualEffectView class]]) {
|
||||||
NSPoint pointInView = [v convertPoint:point fromView:nil];
|
NSPoint pointInView = [v convertPoint:point fromView:nil];
|
||||||
if ([v hitTest:pointInView] && [v mouse:pointInView inRect:v.bounds]) {
|
if ([v hitTest:pointInView] && [v mouse:pointInView inRect:v.bounds]) {
|
||||||
|
|
@ -46,13 +46,19 @@ void swizzledMouseEvent(id obj, SEL sel, NSEvent* theEvent) {
|
||||||
&kIsDraggableKey);
|
&kIsDraggableKey);
|
||||||
NSNumber* isDragging = objc_getAssociatedObject(obj,
|
NSNumber* isDragging = objc_getAssociatedObject(obj,
|
||||||
&kIsDraggingKey);
|
&kIsDraggingKey);
|
||||||
|
NSNumber* previousEventType = objc_getAssociatedObject(obj,
|
||||||
|
&kMouseEventTypeKey);
|
||||||
|
|
||||||
if ([theEvent type] == NSEventTypeLeftMouseDown && isDraggable.boolValue) {
|
if ([theEvent type] == NSEventTypeLeftMouseDown && isDraggable.boolValue) {
|
||||||
NSView* self = obj;
|
NSView* self = obj;
|
||||||
[self.window performWindowDragWithEvent:theEvent];
|
[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,
|
objc_setAssociatedObject(obj,
|
||||||
&kIsDraggingKey,
|
&kIsDraggingKey,
|
||||||
@(YES),
|
@(YES),
|
||||||
|
|
@ -67,6 +73,11 @@ void swizzledMouseEvent(id obj, SEL sel, NSEvent* theEvent) {
|
||||||
} else {
|
} else {
|
||||||
((void(*) (id, SEL, NSEvent*))g_originalMouseEvent)(obj, sel, theEvent);
|
((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) {
|
void Setup(const Napi::CallbackInfo &info) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue