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

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

Issue 1893523002: MacViews: Allow force touch in views::Textfield Base URL: https://chromium.googlesource.com/chromium/src.git@20160415-Mac-ForceTouch
Patch Set: Created 4 years, 8 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/base/ime/text_input_client.h ('k') | no next file » | 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 6d72fef5cf7ece1d35262f4b7b1a572622710f05..95d84887cf77f131efa7fb0f89c4dc0dc2763b3c 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -160,6 +160,12 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
return union_rect;
}
+NSAttributedString* AttributedStringFromRenderText(
+ const gfx::RenderText* render_text,
+ const gfx::Range& range) {
+ return ...
+}
+
} // namespace
@interface BridgedContentView ()
@@ -403,6 +409,28 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
hostedView_->GetWidget()->OnMouseEvent(&event);
}
+- (void)forceTouchEvent:(NSEvent*)theEvent {
+ if (!textInputClient_ || !ui::ForceTouchInvokesQuickLook())
+ return;
+
+ ui::MouseEvent event(theEvent);
+ gfx::Range range;
+ gfx::Point baselinePoint;
+ const gfx::RenderText* renderText =
+ textInputClient_->GetStringAtPointInWindow(event.location(), &range,
+ &baselinePoint);
+ if (!renderText)
+ return;
+
+ NSAttributedString* attributedString =
+ AttributedStringFromRenderText(renderText, range);
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self showDefinitionForAttributedString:attributedString
+ atPoint:baselinePoint];
+ });
+}
+
// NSView implementation.
- (BOOL)acceptsFirstResponder {
« no previous file with comments | « ui/base/ime/text_input_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698