Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2072653002: Experiments for using textfieldy context menus Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_content_view.mm
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm
index 7fe03cabdef92cc789699397a56e080bc203f291..a3a6884d22a56f9f25b4c8021251384273fb0aa2 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -35,6 +35,22 @@
using views::MenuController;
+@interface TextShim : NSText {
+ BridgedContentView* owner_;
+}
+@end
+
+@implementation TextShim
+
+- (id)initWithOwner:(BridgedContentView*)owner {
+ if ((self = [super initWithFrame:NSZeroRect])) {
+ owner_ = owner;
+ }
+ return self;
+}
+
+@end
+
namespace {
NSString* const kFullKeyboardAccessChangedNotification =
@@ -271,6 +287,8 @@ base::string16 AttributedSubstringForRangeHelper(
userInfo:nil]);
[self addTrackingArea:cursorTrackingArea_.get()];
+ textBridge_.reset([[TextShim alloc] initWithOwner:self]);
+
// Get notified whenever Full Keyboard Access mode is changed.
[[NSDistributedNotificationCenter defaultCenter]
addObserver:self
@@ -366,6 +384,12 @@ base::string16 AttributedSubstringForRangeHelper(
focusManager->SetKeyboardAccessible([NSApp isFullKeyboardAccessEnabled]);
}
+- (NSView*)contextMenuView {
+ if (textInputClient_)
+ return textBridge_;
+ return self;
+}
+
// BridgedContentView private implementation.
- (void)handleKeyEvent:(NSEvent*)theEvent {
@@ -1014,6 +1038,7 @@ base::string16 AttributedSubstringForRangeHelper(
// or (string, string).
BOOL valid = textInputClient_ && ((canWrite && (canRead || !returnType)) ||
(canRead && (canWrite || !sendType)));
+ //NOTREACHED();
return valid ? self : [super validRequestorForSendType:sendType
returnType:returnType];
}
« no previous file with comments | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698