@fluentui-react-native/focus-zone 0.9.8 → 0.9.9
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/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/macos/RCTFocusZone.m +38 -7
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/focus-zone",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Fri, 11 Mar 2022 00:34:24 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/focus-zone_v0.9.9",
|
|
7
|
+
"version": "0.9.9",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "sanajmi@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/focus-zone",
|
|
13
|
+
"commit": "489339a0f6ebd9a4687c1c84e9bf8d274d8806d5",
|
|
14
|
+
"comment": "ContextualMenu macOS: Focus on menu rather than first menu item"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 07 Mar 2022 19:15:33 GMT",
|
|
6
21
|
"tag": "@fluentui-react-native/focus-zone_v0.9.8",
|
|
7
22
|
"version": "0.9.8",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/focus-zone
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 11 Mar 2022 00:34:24 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.9.9
|
|
8
|
+
|
|
9
|
+
Fri, 11 Mar 2022 00:34:24 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- ContextualMenu macOS: Focus on menu rather than first menu item (sanajmi@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.9.8
|
|
8
16
|
|
|
9
|
-
Mon, 07 Mar 2022 19:
|
|
17
|
+
Mon, 07 Mar 2022 19:15:33 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/macos/RCTFocusZone.m
CHANGED
|
@@ -45,6 +45,8 @@ static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSP
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/// Performs a depth first search looking for the first key view in a parent view's view heirarchy.
|
|
49
|
+
/// This function does not take into account the geometric position of the view.
|
|
48
50
|
static NSView *GetFirstKeyViewWithin(NSView *parentView)
|
|
49
51
|
{
|
|
50
52
|
for (NSView *view in [parentView subviews]) {
|
|
@@ -60,6 +62,24 @@ static NSView *GetFirstKeyViewWithin(NSView *parentView)
|
|
|
60
62
|
return nil;
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
/// Performs a depth first search looking for the last key view in a parent view's view heirarchy.
|
|
66
|
+
/// We find the last view by simply reversing the order of the subview array.
|
|
67
|
+
/// This function does not take into account the geometric position of the view.
|
|
68
|
+
static NSView *GetLastKeyViewWithin(NSView *parentView)
|
|
69
|
+
{
|
|
70
|
+
for (NSView *view in [[parentView subviews] reverseObjectEnumerator]) {
|
|
71
|
+
if ([view canBecomeKeyView]) {
|
|
72
|
+
return view;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
NSView *match = GetLastKeyViewWithin(view);
|
|
76
|
+
if (match) {
|
|
77
|
+
return match;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return nil;
|
|
81
|
+
}
|
|
82
|
+
|
|
63
83
|
static NSView *GetFirstResponder(NSWindow *window)
|
|
64
84
|
{
|
|
65
85
|
NSResponder *responder = [window firstResponder];
|
|
@@ -283,6 +303,21 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
|
|
|
283
303
|
|
|
284
304
|
- (NSView *)nextViewToFocusWithFallback:(FocusZoneAction)action
|
|
285
305
|
{
|
|
306
|
+
|
|
307
|
+
// Special case if we're currently focused on self
|
|
308
|
+
NSView *firstResponder = GetFirstResponder([self window]);
|
|
309
|
+
if (self == firstResponder)
|
|
310
|
+
{
|
|
311
|
+
if (action == FocusZoneActionDownArrow)
|
|
312
|
+
{
|
|
313
|
+
return GetFirstKeyViewWithin(self);
|
|
314
|
+
}
|
|
315
|
+
else if (action == FocusZoneActionUpArrow)
|
|
316
|
+
{
|
|
317
|
+
return GetLastKeyViewWithin(self);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
286
321
|
NSView *nextViewToFocus = [self nextViewToFocusForAction:action];
|
|
287
322
|
|
|
288
323
|
if (nextViewToFocus == nil)
|
|
@@ -367,18 +402,14 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
|
|
|
367
402
|
&& (action == FocusZoneActionUpArrow || action == FocusZoneActionDownArrow))
|
|
368
403
|
|| (focusZoneDirection == FocusZoneDirectionNone))
|
|
369
404
|
{
|
|
370
|
-
|
|
405
|
+
passthrough = YES;
|
|
371
406
|
}
|
|
372
407
|
else
|
|
373
408
|
{
|
|
374
409
|
viewToFocus = [self nextViewToFocusWithFallback:action];
|
|
375
410
|
}
|
|
376
411
|
|
|
377
|
-
if (passthrough)
|
|
378
|
-
{
|
|
379
|
-
[super keyDown:event];
|
|
380
|
-
}
|
|
381
|
-
else if (viewToFocus != nil)
|
|
412
|
+
if (!passthrough && viewToFocus != nil)
|
|
382
413
|
{
|
|
383
414
|
[[self window] makeFirstResponder:viewToFocus];
|
|
384
415
|
}
|
|
@@ -398,4 +429,4 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
|
|
|
398
429
|
return @"NavigateStopAtEnds";
|
|
399
430
|
}
|
|
400
431
|
|
|
401
|
-
@end
|
|
432
|
+
@end
|
package/package.json
CHANGED