@geastack/apple 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -26,14 +26,11 @@
|
|
|
26
26
|
#include <vector>
|
|
27
27
|
|
|
28
28
|
// NSTextField defaults to consuming mouse events even when bezeled / editable /
|
|
29
|
-
// selectable are all NO.
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// render non-editable, non-selectable labels via makeTextField, so this is
|
|
35
|
-
// safe; if/when input fields land they'll need their own NSTextField
|
|
36
|
-
// subclass that accepts mouse.
|
|
29
|
+
// selectable are all NO. Keep labels in hit testing so the press bridge can
|
|
30
|
+
// preserve their node identity and bubble through their logical ancestors.
|
|
31
|
+
// Forward mouse handling instead of entering NSTextField's tracking loop;
|
|
32
|
+
// excluding the label from hit testing loses handlers attached to text nodes.
|
|
33
|
+
// Editable controls use GeaInputField and retain normal AppKit text editing.
|
|
37
34
|
// NSTextFieldCell reserves a couple of pixels on each edge for the focus
|
|
38
35
|
// ring even when bezeled/bordered are NO — so a field sized for the
|
|
39
36
|
// measured text width clips a few pixels off the right glyph ("JUMP" →
|
|
@@ -51,7 +48,9 @@
|
|
|
51
48
|
@end
|
|
52
49
|
@implementation GeaLabelTextField
|
|
53
50
|
+ (Class)cellClass { return [GeaTextCell class]; }
|
|
54
|
-
- (
|
|
51
|
+
- (void)mouseDown:(NSEvent *)event { [self.nextResponder mouseDown:event]; }
|
|
52
|
+
- (void)mouseDragged:(NSEvent *)event { [self.nextResponder mouseDragged:event]; }
|
|
53
|
+
- (void)mouseUp:(NSEvent *)event { [self.nextResponder mouseUp:event]; }
|
|
55
54
|
@end
|
|
56
55
|
|
|
57
56
|
// Editable text field used to materialize `<input>` JSX elements. Holds the
|
|
@@ -219,6 +218,14 @@ static int geaKeyCodeForCommand(SEL sel)
|
|
|
219
218
|
@end
|
|
220
219
|
|
|
221
220
|
namespace gea::macos {
|
|
221
|
+
static NSView *hitTestInRoot(NSView *root, NSPoint point)
|
|
222
|
+
{
|
|
223
|
+
// NSView hitTest: takes a point in its SUPERview's coordinates. Test the
|
|
224
|
+
// same root we converted from, not its superview (which expects yet another
|
|
225
|
+
// coordinate space and can select a sibling pane or the surrounding grid).
|
|
226
|
+
return [root hitTest:[root convertPoint:point toView:root.superview]];
|
|
227
|
+
}
|
|
228
|
+
|
|
222
229
|
int nodeIdForView(NSView *view)
|
|
223
230
|
{
|
|
224
231
|
while (view) {
|
|
@@ -304,8 +311,7 @@ int nodeIdForView(NSView *view)
|
|
|
304
311
|
}
|
|
305
312
|
// Mouse-down: hit-test now, remember the node so the move and up
|
|
306
313
|
// phases dispatch to the same target even if the cursor drifts.
|
|
307
|
-
|
|
308
|
-
NSView *hit = [root.superview hitTest:pInSuper];
|
|
314
|
+
NSView *hit = gea::macos::hitTestInRoot(root, pInRoot);
|
|
309
315
|
self.pressedNodeId = gea::macos::nodeIdForView(hit);
|
|
310
316
|
self.startX = x;
|
|
311
317
|
self.startY = y;
|
|
@@ -350,15 +356,14 @@ int nodeIdForView(NSView *view)
|
|
|
350
356
|
(void)gestureRecognizer;
|
|
351
357
|
NSView *root = self.rootView;
|
|
352
358
|
if (!root || !root.window) return YES;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
NSView *hit = [content hitTest:p];
|
|
359
|
+
const NSPoint p = [root convertPoint:event.locationInWindow fromView:nil];
|
|
360
|
+
NSView *hit = gea::macos::hitTestInRoot(root, p);
|
|
356
361
|
for (NSView *v = hit; v != nil; v = v.superview) {
|
|
357
362
|
if ([v isKindOfClass:[NSTextView class]]) return NO;
|
|
358
363
|
if ([v isKindOfClass:[NSTextField class]] && ((NSTextField *)v).isEditable) return NO;
|
|
359
364
|
// Canvas views dispatch their own coordinate-carrying touch events
|
|
360
365
|
// (mouseDown/Dragged/Up in GeaCanvasView) — recognizing here too would
|
|
361
|
-
// double-fire the press
|
|
366
|
+
// double-fire the press.
|
|
362
367
|
if ([v isKindOfClass:[GeaCanvasView class]]) return NO;
|
|
363
368
|
// A scroll container's scroller tracks its own knob drag; recognizing
|
|
364
369
|
// the press here took the whole drag and the knob never moved.
|