forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 148
Add cursor prop to View and Touchables #760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f8e1168
add cursor prop to view
ryanlntn 24b7750
add cursor to touchables
ryanlntn 9429d10
use enum with as many css names and native names as we can support
ryanlntn 84da3f2
clean up
ryanlntn a91c0ec
add cursor to view example
ryanlntn c452cac
update to only CSS kebab-case names
ryanlntn 2a272ed
update examples to use new cursor names
ryanlntn 945549c
update default cursor to arrow
ryanlntn 6b78c52
remove auto case and clean up
ryanlntn b99356f
add cursor to flow types for view and touchables
ryanlntn fce50ea
default to auto; fix arrow; always discard rects
ryanlntn 34275a7
apply patch making it a style prop
ryanlntn f9eaa5e
move enum to RCTCursor
ryanlntn 1a3abaa
add CursorValue flow type
ryanlntn ae09ae4
Merge remote-tracking branch 'microsoft/main' into feat/cursor
3205f54
Add cursor style to View
lyahdav 43542f8
satisfy linter
ryanlntn 4eb3cd5
remove view prop and fix build errors
ryanlntn e6a4b5d
Merge branch 'main' into feat/cursor
mischreiber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <React/RCTConvert.h> | ||
|
||
typedef NS_ENUM(NSInteger, RCTCursor) { | ||
RCTCursorAuto, | ||
RCTCursorArrow, | ||
RCTCursorIBeam, | ||
RCTCursorCrosshair, | ||
RCTCursorClosedHand, | ||
RCTCursorOpenHand, | ||
RCTCursorPointingHand, | ||
RCTCursorResizeLeft, | ||
RCTCursorResizeRight, | ||
RCTCursorResizeLeftRight, | ||
RCTCursorResizeUp, | ||
RCTCursorResizeDown, | ||
RCTCursorResizeUpDown, | ||
RCTCursorDisappearingItem, | ||
RCTCursorIBeamCursorForVerticalLayout, | ||
RCTCursorOperationNotAllowed, | ||
RCTCursorDragLink, | ||
RCTCursorDragCopy, | ||
RCTCursorContextualMenu, | ||
}; | ||
|
||
@interface RCTConvert (RCTCursor) | ||
|
||
+ (RCTCursor)RCTCursor:(id)json; | ||
#if TARGET_OS_OSX // TODO(macOS GH#774) | ||
+ (NSCursor *)NSCursor:(RCTCursor)rctCursor; | ||
#endif // ]TODO(macOS GH#774) | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <React/RCTCursor.h> | ||
|
||
@implementation RCTConvert (RCTCursor) | ||
|
||
RCT_ENUM_CONVERTER( | ||
RCTCursor, | ||
(@{ | ||
@"alias" : @(RCTCursorDragLink), | ||
@"auto" : @(RCTCursorAuto), | ||
@"col-resize" : @(RCTCursorResizeLeftRight), | ||
@"context-menu" : @(RCTCursorContextualMenu), | ||
@"copy" : @(RCTCursorDragCopy), | ||
@"crosshair" : @(RCTCursorCrosshair), | ||
@"default" : @(RCTCursorArrow), | ||
@"disappearing-item" : @(RCTCursorDisappearingItem), | ||
@"e-resize" : @(RCTCursorResizeRight), | ||
@"grab" : @(RCTCursorOpenHand), | ||
@"grabbing" : @(RCTCursorClosedHand), | ||
@"n-resize" : @(RCTCursorResizeUp), | ||
@"no-drop" : @(RCTCursorOperationNotAllowed), | ||
@"not-allowed" : @(RCTCursorOperationNotAllowed), | ||
@"pointer" : @(RCTCursorPointingHand), | ||
@"row-resize" : @(RCTCursorResizeUpDown), | ||
@"s-resize" : @(RCTCursorResizeDown), | ||
@"text" : @(RCTCursorIBeam), | ||
@"vertical-text" : @(RCTCursorIBeamCursorForVerticalLayout), | ||
@"w-resize" : @(RCTCursorResizeLeft), | ||
}), | ||
RCTCursorAuto, | ||
integerValue) | ||
|
||
#if TARGET_OS_OSX // TODO(macOS GH#774) | ||
+ (NSCursor *)NSCursor:(RCTCursor)rctCursor | ||
{ | ||
NSCursor *cursor; | ||
|
||
switch (rctCursor) { | ||
case RCTCursorArrow: | ||
cursor = [NSCursor arrowCursor]; | ||
break; | ||
case RCTCursorClosedHand: | ||
cursor = [NSCursor closedHandCursor]; | ||
break; | ||
case RCTCursorContextualMenu: | ||
cursor = [NSCursor contextualMenuCursor]; | ||
break; | ||
case RCTCursorCrosshair: | ||
cursor = [NSCursor crosshairCursor]; | ||
break; | ||
case RCTCursorDisappearingItem: | ||
cursor = [NSCursor disappearingItemCursor]; | ||
break; | ||
case RCTCursorDragCopy: | ||
cursor = [NSCursor dragCopyCursor]; | ||
break; | ||
case RCTCursorDragLink: | ||
cursor = [NSCursor dragLinkCursor]; | ||
break; | ||
case RCTCursorIBeam: | ||
cursor = [NSCursor IBeamCursor]; | ||
break; | ||
case RCTCursorIBeamCursorForVerticalLayout: | ||
cursor = [NSCursor IBeamCursorForVerticalLayout]; | ||
break; | ||
case RCTCursorOpenHand: | ||
cursor = [NSCursor openHandCursor]; | ||
break; | ||
case RCTCursorOperationNotAllowed: | ||
cursor = [NSCursor operationNotAllowedCursor]; | ||
break; | ||
case RCTCursorPointingHand: | ||
cursor = [NSCursor pointingHandCursor]; | ||
break; | ||
case RCTCursorResizeDown: | ||
cursor = [NSCursor resizeDownCursor]; | ||
break; | ||
case RCTCursorResizeLeft: | ||
cursor = [NSCursor resizeLeftCursor]; | ||
break; | ||
case RCTCursorResizeLeftRight: | ||
cursor = [NSCursor resizeLeftRightCursor]; | ||
break; | ||
case RCTCursorResizeRight: | ||
cursor = [NSCursor resizeRightCursor]; | ||
break; | ||
case RCTCursorResizeUp: | ||
cursor = [NSCursor resizeUpCursor]; | ||
break; | ||
case RCTCursorResizeUpDown: | ||
cursor = [NSCursor resizeUpDownCursor]; | ||
break; | ||
} | ||
|
||
return cursor; | ||
} | ||
#endif // ]TODO(macOS GH#774) | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.