Skip to content

Commit dd2a3f3

Browse files
shwantonShawn DempseySaadnajmi
committed
Only forward click events to NSTextview (microsoft#1515)
* Forward mouse clicks to NSTextView to prevent swallowing of events Change HitTest to forward events correctly Add MouseDown & forward events correctly Add touch handler static methods * Show the NSTextView contextMenu on right click * No need to forward copy to nstextview since it will have first responder upon click * Fix Event mask deprecation warnings * Fix missing macOS tag & extra comment Co-authored-by: Shawn Dempsey <[email protected]> Co-authored-by: Saad Najmi <[email protected]>
1 parent 39ee2a5 commit dd2a3f3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Libraries/Text/Text/RCTTextView.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import <React/RCTFocusChangeEvent.h> // [macOS]
1818

1919
#import <React/RCTTextShadowView.h>
20+
#import <React/RCTTouchHandler.h>
2021

2122
#import <QuartzCore/QuartzCore.h>
2223

@@ -277,7 +278,6 @@ - (void)drawRect:(CGRect)rect
277278
return;
278279
}
279280

280-
281281
NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
282282
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
283283

@@ -490,6 +490,9 @@ - (NSMenu *)textView:(NSTextView *)view menu:(NSMenu *)menu forEvent:(NSEvent *)
490490
for (NSMenuItem* item in [_additionalMenuItems reverseObjectEnumerator]) {
491491
[menu insertItem:item atIndex:0];
492492
}
493+
} else {
494+
// Clear selection for single clicks.
495+
_textView.selectedRange = NSMakeRange(NSNotFound, 0);
493496
}
494497

495498
return menu;

Libraries/Text/TextInput/Singleline/RCTUITextField.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#import <React/RCTBackedTextInputDelegateAdapter.h>
1313
#import <React/RCTBackedTextInputDelegate.h> // [macOS]
1414
#import <React/RCTTextAttributes.h>
15-
15+
#import <React/RCTTouchHandler.h> // [TODO(macOS GH#774)
1616

1717
#if TARGET_OS_OSX // [TODO(macOS GH#774)
1818
#import <React/RCTTouchHandler.h>
@@ -437,7 +437,7 @@ - (CGRect)editingRectForBounds:(CGRect)bounds
437437

438438
#else // [macOS
439439

440-
#pragma mark - NSTextViewDelegate methods
440+
#pragma mark - NSTextFieldDelegate methods
441441

442442
- (void)textDidChange:(NSNotification *)notification
443443
{

0 commit comments

Comments
 (0)