react-native-macos 0.66.72 → 0.66.75
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/Libraries/Components/ScrollView/ScrollView.js +0 -77
- package/Libraries/Components/View/ViewPropTypes.js +0 -6
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Lists/FlatList.js +37 -1
- package/Libraries/Lists/VirtualizedList.js +112 -83
- package/Libraries/Lists/VirtualizedSectionList.js +9 -5
- package/Libraries/Types/CoreEventTypes.js +0 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Views/RCTView.h +4 -6
- package/React/Views/RCTView.m +31 -200
- package/React/Views/RCTViewKeyboardEvent.h +6 -28
- package/React/Views/RCTViewKeyboardEvent.m +66 -61
- package/React/Views/RCTViewManager.m +2 -21
- package/React/Views/ScrollView/RCTScrollView.h +0 -1
- package/React/Views/ScrollView/RCTScrollView.m +55 -53
- package/React/Views/ScrollView/RCTScrollViewManager.m +0 -1
- package/React/Views/UIView+React.m +18 -10
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
package/React/Views/RCTView.m
CHANGED
|
@@ -164,7 +164,6 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS I
|
|
|
164
164
|
_hitTestEdgeInsets = UIEdgeInsetsZero;
|
|
165
165
|
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
166
166
|
_transform3D = CATransform3DIdentity;
|
|
167
|
-
_shadowColor = nil;
|
|
168
167
|
#endif // TODO(macOS GH#774)
|
|
169
168
|
|
|
170
169
|
_backgroundColor = super.backgroundColor;
|
|
@@ -727,49 +726,20 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
|
|
|
727
726
|
#endif // TODO(macOS GH#774)
|
|
728
727
|
|
|
729
728
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
730
|
-
|
|
729
|
+
// Workaround AppKit issue with directly manipulating the view layer's shadow.
|
|
730
|
+
- (NSShadow*)shadow
|
|
731
731
|
{
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
_shadowColor = shadowColor;
|
|
735
|
-
[self didUpdateShadow];
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
- (void)setShadowOffset:(CGSize)shadowOffset
|
|
740
|
-
{
|
|
741
|
-
if (!CGSizeEqualToSize(_shadowOffset, shadowOffset))
|
|
742
|
-
{
|
|
743
|
-
_shadowOffset = shadowOffset;
|
|
744
|
-
[self didUpdateShadow];
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
- (void)setShadowOpacity:(CGFloat)shadowOpacity
|
|
749
|
-
{
|
|
750
|
-
if (_shadowOpacity != shadowOpacity)
|
|
751
|
-
{
|
|
752
|
-
_shadowOpacity = shadowOpacity;
|
|
753
|
-
[self didUpdateShadow];
|
|
754
|
-
}
|
|
755
|
-
}
|
|
732
|
+
CALayer *layer = self.layer;
|
|
733
|
+
NSShadow *shadow = nil;
|
|
756
734
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
if (_shadowRadius != shadowRadius)
|
|
760
|
-
{
|
|
761
|
-
_shadowRadius = shadowRadius;
|
|
762
|
-
[self didUpdateShadow];
|
|
763
|
-
}
|
|
764
|
-
}
|
|
735
|
+
if (layer.shadowColor != nil && layer.shadowOpacity > 0) {
|
|
736
|
+
shadow = [NSShadow new];
|
|
765
737
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
shadow.shadowBlurRadius = [self shadowRadius];
|
|
772
|
-
[self setShadow:shadow];
|
|
738
|
+
shadow.shadowColor = [[NSColor colorWithCGColor:layer.shadowColor] colorWithAlphaComponent:layer.shadowOpacity];
|
|
739
|
+
shadow.shadowOffset = layer.shadowOffset;
|
|
740
|
+
shadow.shadowBlurRadius = layer.shadowRadius;
|
|
741
|
+
}
|
|
742
|
+
return shadow;
|
|
773
743
|
}
|
|
774
744
|
|
|
775
745
|
- (void)viewDidMoveToWindow
|
|
@@ -1643,177 +1613,38 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1643
1613
|
#pragma mark - Keyboard Events
|
|
1644
1614
|
|
|
1645
1615
|
#if TARGET_OS_OSX
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
NSString
|
|
1649
|
-
NSString*
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
BOOL shiftKey = NO;
|
|
1655
|
-
BOOL controlKey = NO;
|
|
1656
|
-
BOOL optionKey = NO;
|
|
1657
|
-
BOOL commandKey = NO;
|
|
1658
|
-
BOOL numericPadKey = NO;
|
|
1659
|
-
BOOL helpKey = NO;
|
|
1660
|
-
BOOL functionKey = NO;
|
|
1661
|
-
// commonly used key short-cuts
|
|
1662
|
-
BOOL leftArrowKey = NO;
|
|
1663
|
-
BOOL rightArrowKey = NO;
|
|
1664
|
-
BOOL upArrowKey = NO;
|
|
1665
|
-
BOOL downArrowKey = NO;
|
|
1666
|
-
BOOL tabKeyPressed = NO;
|
|
1667
|
-
BOOL escapeKeyPressed = NO;
|
|
1668
|
-
NSString *key = event.charactersIgnoringModifiers;
|
|
1669
|
-
if ([key length] == 0) {
|
|
1670
|
-
return nil;
|
|
1671
|
-
}
|
|
1672
|
-
unichar const code = [key characterAtIndex:0];
|
|
1673
|
-
|
|
1674
|
-
// detect arrow key presses
|
|
1675
|
-
if (code == NSLeftArrowFunctionKey) {
|
|
1676
|
-
leftArrowKey = YES;
|
|
1677
|
-
} else if (code == NSRightArrowFunctionKey) {
|
|
1678
|
-
rightArrowKey = YES;
|
|
1679
|
-
} else if (code == NSUpArrowFunctionKey) {
|
|
1680
|
-
upArrowKey = YES;
|
|
1681
|
-
} else if (code == NSDownArrowFunctionKey) {
|
|
1682
|
-
downArrowKey = YES;
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
// detect special key presses via the key code
|
|
1686
|
-
switch (event.keyCode) {
|
|
1687
|
-
case 48: // Tab
|
|
1688
|
-
tabKeyPressed = YES;
|
|
1689
|
-
break;
|
|
1690
|
-
case 53: // Escape
|
|
1691
|
-
escapeKeyPressed = YES;
|
|
1692
|
-
break;
|
|
1693
|
-
default:
|
|
1694
|
-
break;
|
|
1616
|
+
- (RCTViewKeyboardEvent*)keyboardEvent:(NSEvent*)event {
|
|
1617
|
+
BOOL keyDown = event.type == NSEventTypeKeyDown;
|
|
1618
|
+
NSArray<NSString *> *validKeys = keyDown ? self.validKeysDown : self.validKeysUp;
|
|
1619
|
+
NSString *key = [RCTViewKeyboardEvent keyFromEvent:event];
|
|
1620
|
+
|
|
1621
|
+
// Only post events for keys we care about
|
|
1622
|
+
if (![validKeys containsObject:key]) {
|
|
1623
|
+
return nil;
|
|
1695
1624
|
}
|
|
1696
1625
|
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
} else if (event.modifierFlags & NSEventModifierFlagCommand) {
|
|
1707
|
-
commandKey = YES;
|
|
1708
|
-
} else if (event.modifierFlags & NSEventModifierFlagNumericPad) {
|
|
1709
|
-
numericPadKey = YES;
|
|
1710
|
-
} else if (event.modifierFlags & NSEventModifierFlagHelp) {
|
|
1711
|
-
helpKey = YES;
|
|
1712
|
-
} else if (event.modifierFlags & NSEventModifierFlagFunction) {
|
|
1713
|
-
functionKey = YES;
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
RCTViewKeyboardEvent *keyboardEvent = nil;
|
|
1717
|
-
// only post events for keys we care about
|
|
1718
|
-
if (downPress) {
|
|
1719
|
-
NSString *keyToReturn = [self keyIsValid:key left:leftArrowKey right:rightArrowKey up:upArrowKey down:downArrowKey tabKey:tabKeyPressed escapeKey:escapeKeyPressed validKeys:[self validKeysDown]];
|
|
1720
|
-
if (keyToReturn != nil) {
|
|
1721
|
-
keyboardEvent = [RCTViewKeyboardEvent keyDownEventWithReactTag:self.reactTag
|
|
1722
|
-
capsLockKey:capsLockKey
|
|
1723
|
-
shiftKey:shiftKey
|
|
1724
|
-
ctrlKey:controlKey
|
|
1725
|
-
altKey:optionKey
|
|
1726
|
-
metaKey:commandKey
|
|
1727
|
-
numericPadKey:numericPadKey
|
|
1728
|
-
helpKey:helpKey
|
|
1729
|
-
functionKey:functionKey
|
|
1730
|
-
leftArrowKey:leftArrowKey
|
|
1731
|
-
rightArrowKey:rightArrowKey
|
|
1732
|
-
upArrowKey:upArrowKey
|
|
1733
|
-
downArrowKey:downArrowKey
|
|
1734
|
-
key:keyToReturn];
|
|
1735
|
-
}
|
|
1736
|
-
} else {
|
|
1737
|
-
NSString *keyToReturn = [self keyIsValid:key left:leftArrowKey right:rightArrowKey up:upArrowKey down:downArrowKey tabKey:tabKeyPressed escapeKey:escapeKeyPressed validKeys:[self validKeysUp]];
|
|
1738
|
-
if (keyToReturn != nil) {
|
|
1739
|
-
keyboardEvent = [RCTViewKeyboardEvent keyUpEventWithReactTag:self.reactTag
|
|
1740
|
-
capsLockKey:capsLockKey
|
|
1741
|
-
shiftKey:shiftKey
|
|
1742
|
-
ctrlKey:controlKey
|
|
1743
|
-
altKey:optionKey
|
|
1744
|
-
metaKey:commandKey
|
|
1745
|
-
numericPadKey:numericPadKey
|
|
1746
|
-
helpKey:helpKey
|
|
1747
|
-
functionKey:functionKey
|
|
1748
|
-
leftArrowKey:leftArrowKey
|
|
1749
|
-
rightArrowKey:rightArrowKey
|
|
1750
|
-
upArrowKey:upArrowKey
|
|
1751
|
-
downArrowKey:downArrowKey
|
|
1752
|
-
key:keyToReturn];
|
|
1626
|
+
return [RCTViewKeyboardEvent keyEventFromEvent:event reactTag:self.reactTag];
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
- (BOOL)handleKeyboardEvent:(NSEvent *)event {
|
|
1630
|
+
if (event.type == NSEventTypeKeyDown ? self.onKeyDown : self.onKeyUp) {
|
|
1631
|
+
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event];
|
|
1632
|
+
if (keyboardEvent) {
|
|
1633
|
+
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1634
|
+
return YES;
|
|
1753
1635
|
}
|
|
1754
1636
|
}
|
|
1755
|
-
return
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
// check if the user typed key matches a key we need to send an event for
|
|
1759
|
-
// translate key codes over to JS compatible keys
|
|
1760
|
-
- (NSString*)keyIsValid:(NSString*)key left:(BOOL)leftArrowPressed right:(BOOL)rightArrowPressed up:(BOOL)upArrowPressed down:(BOOL)downArrowPressed tabKey:(BOOL)tabKeyPressed escapeKey:(BOOL)escapeKeyPressed validKeys:(NSArray<NSString*>*)validKeys {
|
|
1761
|
-
NSString *keyToReturn = key;
|
|
1762
|
-
|
|
1763
|
-
// Allow the flexibility of defining special keys in multiple ways
|
|
1764
|
-
BOOL enterKeyValidityCheck = [key isEqualToString:@"\r"] && ([validKeys containsObject:@"Enter"] || [validKeys containsObject:@"\r"]);
|
|
1765
|
-
BOOL tabKeyValidityCheck = tabKeyPressed && ([validKeys containsObject:@"Tab"]); // tab has to be checked via a key code so we can't just use the key itself here
|
|
1766
|
-
BOOL escapeKeyValidityCheck = escapeKeyPressed && ([validKeys containsObject:@"Esc"] || [validKeys containsObject:@"Escape"]); // escape has to be checked via a key code so we can't just use the key itself here
|
|
1767
|
-
BOOL leftArrowValidityCheck = [validKeys containsObject:leftArrowPressKey] && leftArrowPressed;
|
|
1768
|
-
BOOL rightArrowValidityCheck = [validKeys containsObject:rightArrowPressKey] && rightArrowPressed;
|
|
1769
|
-
BOOL upArrowValidityCheck = [validKeys containsObject:upArrowPressKey] && upArrowPressed;
|
|
1770
|
-
BOOL downArrowValidityCheck = [validKeys containsObject:downArrowPressKey] && downArrowPressed;
|
|
1771
|
-
|
|
1772
|
-
if (tabKeyValidityCheck) {
|
|
1773
|
-
keyToReturn = @"Tab";
|
|
1774
|
-
} else if (escapeKeyValidityCheck) {
|
|
1775
|
-
keyToReturn = @"Escape";
|
|
1776
|
-
} else if (enterKeyValidityCheck) {
|
|
1777
|
-
keyToReturn = @"Enter";
|
|
1778
|
-
} else if (leftArrowValidityCheck) {
|
|
1779
|
-
keyToReturn = leftArrowPressKey;
|
|
1780
|
-
} else if (rightArrowValidityCheck) {
|
|
1781
|
-
keyToReturn = rightArrowPressKey;
|
|
1782
|
-
} else if (upArrowValidityCheck) {
|
|
1783
|
-
keyToReturn = upArrowPressKey;
|
|
1784
|
-
} else if (downArrowValidityCheck) {
|
|
1785
|
-
keyToReturn = downArrowPressKey;
|
|
1786
|
-
} else if (![validKeys containsObject:key]) {
|
|
1787
|
-
keyToReturn = nil;
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
return keyToReturn;
|
|
1637
|
+
return NO;
|
|
1791
1638
|
}
|
|
1792
1639
|
|
|
1793
1640
|
- (void)keyDown:(NSEvent *)event {
|
|
1794
|
-
if (self
|
|
1795
|
-
[super keyDown:event];
|
|
1796
|
-
return;
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event downPress:YES];
|
|
1800
|
-
if (keyboardEvent != nil) {
|
|
1801
|
-
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1802
|
-
} else {
|
|
1641
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1803
1642
|
[super keyDown:event];
|
|
1804
1643
|
}
|
|
1805
1644
|
}
|
|
1806
1645
|
|
|
1807
1646
|
- (void)keyUp:(NSEvent *)event {
|
|
1808
|
-
if (self
|
|
1809
|
-
[super keyUp:event];
|
|
1810
|
-
return;
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event downPress:NO];
|
|
1814
|
-
if (keyboardEvent != nil) {
|
|
1815
|
-
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1816
|
-
} else {
|
|
1647
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1817
1648
|
[super keyUp:event];
|
|
1818
1649
|
}
|
|
1819
1650
|
}
|
|
@@ -7,33 +7,11 @@
|
|
|
7
7
|
#import <React/RCTComponentEvent.h>
|
|
8
8
|
|
|
9
9
|
@interface RCTViewKeyboardEvent : RCTComponentEvent
|
|
10
|
-
+ (instancetype)keyDownEventWithReactTag:(NSNumber *)reactTag
|
|
11
|
-
capsLockKey:(BOOL)capsLockKey
|
|
12
|
-
shiftKey:(BOOL)shiftKey
|
|
13
|
-
ctrlKey:(BOOL)controlKey
|
|
14
|
-
altKey:(BOOL)optionKey
|
|
15
|
-
metaKey:(BOOL)commandKey
|
|
16
|
-
numericPadKey:(BOOL)numericPadKey
|
|
17
|
-
helpKey:(BOOL)helpKey
|
|
18
|
-
functionKey:(BOOL)functionKey
|
|
19
|
-
leftArrowKey:(BOOL)leftArrowKey
|
|
20
|
-
rightArrowKey:(BOOL)rightArrowKey
|
|
21
|
-
upArrowKey:(BOOL)upArrowKey
|
|
22
|
-
downArrowKey:(BOOL)downArrowKey
|
|
23
|
-
key:(NSString *)key;
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
numericPadKey:(BOOL)numericPadKey
|
|
32
|
-
helpKey:(BOOL)helpKey
|
|
33
|
-
functionKey:(BOOL)functionKey
|
|
34
|
-
leftArrowKey:(BOOL)leftArrowKey
|
|
35
|
-
rightArrowKey:(BOOL)rightArrowKey
|
|
36
|
-
upArrowKey:(BOOL)upArrowKey
|
|
37
|
-
downArrowKey:(BOOL)downArrowKey
|
|
38
|
-
key:(NSString *)key;
|
|
11
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
12
|
+
+ (NSDictionary *)bodyFromEvent:(NSEvent *)event;
|
|
13
|
+
+ (NSString *)keyFromEvent:(NSEvent *)event;
|
|
14
|
+
+ (instancetype)keyEventFromEvent:(NSEvent *)event reactTag:(NSNumber *)reactTag;
|
|
15
|
+
#endif // TODO(macOS GH#774)
|
|
16
|
+
|
|
39
17
|
@end
|
|
@@ -9,69 +9,74 @@
|
|
|
9
9
|
#import <React/RCTAssert.h>
|
|
10
10
|
|
|
11
11
|
@implementation RCTViewKeyboardEvent
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@"shiftKey" : @(shiftKey),
|
|
31
|
-
@"ctrlKey" : @(controlKey),
|
|
32
|
-
@"altKey" : @(optionKey),
|
|
33
|
-
@"metaKey" : @(commandKey),
|
|
34
|
-
@"numericPadKey" : @(numericPadKey),
|
|
35
|
-
@"helpKey" : @(helpKey),
|
|
36
|
-
@"functionKey" : @(functionKey),
|
|
37
|
-
@"ArrowLeft" : @(leftArrowKey),
|
|
38
|
-
@"ArrowRight" : @(rightArrowKey),
|
|
39
|
-
@"ArrowUp" : @(upArrowKey),
|
|
40
|
-
@"ArrowDown" : @(downArrowKey),
|
|
41
|
-
@"key" : key }];
|
|
42
|
-
return event;
|
|
12
|
+
|
|
13
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
14
|
+
+ (NSDictionary *)bodyFromEvent:(NSEvent *)event
|
|
15
|
+
{
|
|
16
|
+
NSString *key = [self keyFromEvent:event];
|
|
17
|
+
NSEventModifierFlags modifierFlags = event.modifierFlags;
|
|
18
|
+
|
|
19
|
+
return @{
|
|
20
|
+
@"key" : key,
|
|
21
|
+
@"capsLockKey" : (modifierFlags & NSEventModifierFlagCapsLock) ? @YES : @NO,
|
|
22
|
+
@"shiftKey" : (modifierFlags & NSEventModifierFlagShift) ? @YES : @NO,
|
|
23
|
+
@"ctrlKey" : (modifierFlags & NSEventModifierFlagControl) ? @YES : @NO,
|
|
24
|
+
@"altKey" : (modifierFlags & NSEventModifierFlagOption) ? @YES : @NO,
|
|
25
|
+
@"metaKey" : (modifierFlags & NSEventModifierFlagCommand) ? @YES : @NO,
|
|
26
|
+
@"numericPadKey" : (modifierFlags & NSEventModifierFlagNumericPad) ? @YES : @NO,
|
|
27
|
+
@"helpKey" : (modifierFlags & NSEventModifierFlagHelp) ? @YES : @NO,
|
|
28
|
+
@"functionKey" : (modifierFlags & NSEventModifierFlagFunction) ? @YES : @NO,
|
|
29
|
+
};
|
|
43
30
|
}
|
|
44
31
|
|
|
45
|
-
+(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
32
|
+
+ (NSString *)keyFromEvent:(NSEvent *)event
|
|
33
|
+
{
|
|
34
|
+
NSString *key = event.charactersIgnoringModifiers;
|
|
35
|
+
unichar const code = key.length > 0 ? [key characterAtIndex:0] : 0;
|
|
36
|
+
|
|
37
|
+
if (event.keyCode == 48) {
|
|
38
|
+
return @"Tab";
|
|
39
|
+
} else if (event.keyCode == 53) {
|
|
40
|
+
return @"Escape";
|
|
41
|
+
} else if (code == NSEnterCharacter || code == NSNewlineCharacter || code == NSCarriageReturnCharacter) {
|
|
42
|
+
return @"Enter";
|
|
43
|
+
} else if (code == NSLeftArrowFunctionKey) {
|
|
44
|
+
return @"ArrowLeft";
|
|
45
|
+
} else if (code == NSRightArrowFunctionKey) {
|
|
46
|
+
return @"ArrowRight";
|
|
47
|
+
} else if (code == NSUpArrowFunctionKey) {
|
|
48
|
+
return @"ArrowUp";
|
|
49
|
+
} else if (code == NSDownArrowFunctionKey) {
|
|
50
|
+
return @"ArrowDown";
|
|
51
|
+
} else if (code == NSBackspaceCharacter || code == NSDeleteCharacter) {
|
|
52
|
+
return @"Backspace";
|
|
53
|
+
} else if (code == NSDeleteFunctionKey) {
|
|
54
|
+
return @"Delete";
|
|
55
|
+
} else if (code == NSHomeFunctionKey) {
|
|
56
|
+
return @"Home";
|
|
57
|
+
} else if (code == NSEndFunctionKey) {
|
|
58
|
+
return @"End";
|
|
59
|
+
} else if (code == NSPageUpFunctionKey) {
|
|
60
|
+
return @"PageUp";
|
|
61
|
+
} else if (code == NSPageDownFunctionKey) {
|
|
62
|
+
return @"PageDown";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return key;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Keyboard mappings are aligned cross-platform as much as possible as per this doc https://github.com/microsoft/react-native-windows/blob/master/vnext/proposals/active/keyboard-reconcile-desktop.md
|
|
69
|
+
+ (instancetype)keyEventFromEvent:(NSEvent *)event reactTag:(NSNumber *)reactTag
|
|
70
|
+
{
|
|
71
|
+
// Ignore "dead keys" (key press that waits for another key to make a character)
|
|
72
|
+
if (!event.charactersIgnoringModifiers.length) {
|
|
73
|
+
return nil;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return [[self alloc] initWithName:(event.type == NSEventTypeKeyDown ? @"keyDown" : @"keyUp")
|
|
77
|
+
viewTag:reactTag
|
|
78
|
+
body:[self bodyFromEvent:event]];
|
|
75
79
|
}
|
|
80
|
+
#endif // TODO(macOS GH#774)
|
|
76
81
|
|
|
77
82
|
@end
|
|
@@ -192,19 +192,10 @@ RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
|
|
|
192
192
|
#else // [TODO(macOS GH#774)
|
|
193
193
|
RCT_REMAP_VIEW_PROPERTY(opacity, alphaValue, CGFloat)
|
|
194
194
|
#endif // ]TODO(macOS GH#774)
|
|
195
|
-
|
|
196
|
-
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
197
195
|
RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor, CGColor)
|
|
198
196
|
RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize)
|
|
199
197
|
RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, float)
|
|
200
198
|
RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius, CGFloat)
|
|
201
|
-
#else // [TODO(macOS GH#774)
|
|
202
|
-
RCT_EXPORT_VIEW_PROPERTY(shadowColor, NSColor)
|
|
203
|
-
RCT_EXPORT_VIEW_PROPERTY(shadowOffset, CGSize)
|
|
204
|
-
RCT_EXPORT_VIEW_PROPERTY(shadowOpacity, CGFloat)
|
|
205
|
-
RCT_EXPORT_VIEW_PROPERTY(shadowRadius, CGFloat)
|
|
206
|
-
#endif // ]TODO(macOS GH#774)
|
|
207
|
-
|
|
208
199
|
RCT_REMAP_VIEW_PROPERTY(needsOffscreenAlphaCompositing, layer.allowsGroupOpacity, BOOL)
|
|
209
200
|
RCT_CUSTOM_VIEW_PROPERTY(overflow, YGOverflow, RCTView)
|
|
210
201
|
{
|
|
@@ -495,18 +486,8 @@ RCT_EXPORT_VIEW_PROPERTY(onDragLeave, RCTDirectEventBlock)
|
|
|
495
486
|
RCT_EXPORT_VIEW_PROPERTY(onDrop, RCTDirectEventBlock)
|
|
496
487
|
RCT_EXPORT_VIEW_PROPERTY(onKeyDown, RCTDirectEventBlock) // macOS keyboard events
|
|
497
488
|
RCT_EXPORT_VIEW_PROPERTY(onKeyUp, RCTDirectEventBlock) // macOS keyboard events
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
if ([view respondsToSelector:@selector(setValidKeysDown:)]) {
|
|
501
|
-
view.validKeysDown = [RCTConvert NSArray:json];
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
RCT_CUSTOM_VIEW_PROPERTY(validKeysUp, NSArray<NSString*>, RCTView)
|
|
505
|
-
{
|
|
506
|
-
if ([view respondsToSelector:@selector(setValidKeysUp:)]) {
|
|
507
|
-
view.validKeysUp = [RCTConvert NSArray:json];
|
|
508
|
-
}
|
|
509
|
-
}
|
|
489
|
+
RCT_EXPORT_VIEW_PROPERTY(validKeysDown, NSArray<NSString*>)
|
|
490
|
+
RCT_EXPORT_VIEW_PROPERTY(validKeysUp, NSArray<NSString*>)
|
|
510
491
|
#endif // ]TODO(macOS GH#774)
|
|
511
492
|
#if TARGET_OS_OSX // [TODO(macOS GH#768)
|
|
512
493
|
RCT_CUSTOM_VIEW_PROPERTY(nextKeyViewTag, NSNumber, RCTView)
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
@property (nonatomic, copy) RCTDirectEventBlock onScrollEndDrag;
|
|
65
65
|
@property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollBegin;
|
|
66
66
|
@property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollEnd;
|
|
67
|
-
@property (nonatomic, copy) RCTDirectEventBlock onScrollKeyDown; // TODO(macOS GH#774)
|
|
68
67
|
@property (nonatomic, copy) RCTDirectEventBlock onPreferredScrollerStyleDidChange; // TODO(macOS GH#774)
|
|
69
68
|
|
|
70
69
|
- (void)flashScrollIndicators; // TODO(macOS GH#774)
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
24
24
|
#import "RCTRefreshControl.h"
|
|
25
|
+
#else
|
|
26
|
+
#import "RCTViewKeyboardEvent.h"
|
|
25
27
|
#endif // TODO(macOS GH#774)
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -1183,59 +1185,58 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
|
|
1183
1185
|
}];
|
|
1184
1186
|
}
|
|
1185
1187
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
- (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode
|
|
1189
|
-
{
|
|
1190
|
-
switch (keyCode)
|
|
1191
|
-
{
|
|
1192
|
-
case 36:
|
|
1193
|
-
return @"ENTER";
|
|
1194
|
-
|
|
1195
|
-
case 116:
|
|
1196
|
-
return @"PAGE_UP";
|
|
1197
|
-
|
|
1198
|
-
case 121:
|
|
1199
|
-
return @"PAGE_DOWN";
|
|
1200
|
-
|
|
1201
|
-
case 123:
|
|
1202
|
-
return @"LEFT_ARROW";
|
|
1203
|
-
|
|
1204
|
-
case 124:
|
|
1205
|
-
return @"RIGHT_ARROW";
|
|
1206
|
-
|
|
1207
|
-
case 125:
|
|
1208
|
-
return @"DOWN_ARROW";
|
|
1188
|
+
// [TODO(macOS GH#774)
|
|
1189
|
+
#pragma mark - Keyboard Events
|
|
1209
1190
|
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
{
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1191
|
+
#if TARGET_OS_OSX
|
|
1192
|
+
- (RCTViewKeyboardEvent*)keyboardEvent:(NSEvent*)event {
|
|
1193
|
+
BOOL keyDown = event.type == NSEventTypeKeyDown;
|
|
1194
|
+
NSArray<NSString *> *validKeys = keyDown ? self.validKeysDown : self.validKeysUp;
|
|
1195
|
+
NSString *key = [RCTViewKeyboardEvent keyFromEvent:event];
|
|
1196
|
+
|
|
1197
|
+
// Only post events for keys we care about
|
|
1198
|
+
if (![validKeys containsObject:key]) {
|
|
1199
|
+
return nil;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
return [RCTViewKeyboardEvent keyEventFromEvent:event reactTag:self.reactTag];
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
- (BOOL)handleKeyboardEvent:(NSEvent *)event {
|
|
1206
|
+
if (event.type == NSEventTypeKeyDown ? self.onKeyDown : self.onKeyUp) {
|
|
1207
|
+
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event];
|
|
1208
|
+
if (keyboardEvent) {
|
|
1209
|
+
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1210
|
+
return YES;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
return NO;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
- (void)keyDown:(NSEvent *)event {
|
|
1217
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1218
|
+
[super keyDown:event];
|
|
1219
|
+
|
|
1220
|
+
// AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
|
|
1221
|
+
// automatically scroll to make the view visible to make it navigable via keyboard.
|
|
1222
|
+
NSString *key = [RCTViewKeyboardEvent keyFromEvent:event];
|
|
1223
|
+
if ([key isEqualToString:@"Tab"]) {
|
|
1224
|
+
id firstResponder = [[self window] firstResponder];
|
|
1225
|
+
if ([firstResponder isKindOfClass:[NSView class]] &&
|
|
1226
|
+
[firstResponder isDescendantOf:[_scrollView documentView]]) {
|
|
1227
|
+
NSView *view = (NSView*)firstResponder;
|
|
1228
|
+
NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
|
|
1229
|
+
[view convertRect:view.frame toView:_scrollView.documentView];
|
|
1230
|
+
[[_scrollView documentView] scrollRectToVisible:visibleRect];
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
- (void)keyUp:(NSEvent *)event {
|
|
1237
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1238
|
+
[super keyUp:event];
|
|
1239
|
+
}
|
|
1239
1240
|
}
|
|
1240
1241
|
|
|
1241
1242
|
static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) {
|
|
@@ -1250,7 +1251,8 @@ static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) {
|
|
|
1250
1251
|
- (void)preferredScrollerStyleDidChange:(__unused NSNotification *)notification {
|
|
1251
1252
|
RCT_SEND_SCROLL_EVENT(onPreferredScrollerStyleDidChange, (@{ @"preferredScrollerStyle": RCTStringForScrollerStyle([NSScroller preferredScrollerStyle])}));
|
|
1252
1253
|
}
|
|
1253
|
-
#endif
|
|
1254
|
+
#endif
|
|
1255
|
+
// ]TODO(macOS GH#774)
|
|
1254
1256
|
|
|
1255
1257
|
// Note: setting several properties of UIScrollView has the effect of
|
|
1256
1258
|
// resetting its contentOffset to {0, 0}. To prevent this, we generate
|
|
@@ -103,7 +103,6 @@ RCT_EXPORT_VIEW_PROPERTY(onScrollToTop, RCTDirectEventBlock)
|
|
|
103
103
|
RCT_EXPORT_VIEW_PROPERTY(onScrollEndDrag, RCTDirectEventBlock)
|
|
104
104
|
RCT_EXPORT_VIEW_PROPERTY(onMomentumScrollBegin, RCTDirectEventBlock)
|
|
105
105
|
RCT_EXPORT_VIEW_PROPERTY(onMomentumScrollEnd, RCTDirectEventBlock)
|
|
106
|
-
RCT_EXPORT_OSX_VIEW_PROPERTY(onScrollKeyDown, RCTDirectEventBlock) // TODO(macOS GH#774)
|
|
107
106
|
RCT_EXPORT_OSX_VIEW_PROPERTY(onPreferredScrollerStyleDidChange, RCTDirectEventBlock) // TODO(macOS GH#774)
|
|
108
107
|
RCT_EXPORT_VIEW_PROPERTY(inverted, BOOL)
|
|
109
108
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */
|