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

Unified Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 159105: [Mac] Detect control-key changes in autocomplete field. (Closed)
Patch Set: More comments about Control handling. Created 11 years, 5 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
Index: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index 6f441fa8e2ede59da51b2dcd4bf7f0ffb7497013..7bbc086a194e9d14bb6493d8380b363962ac932d 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -579,6 +579,10 @@ void AutocompleteEditViewMac::OnPaste() {
OnAfterPossibleChange();
}
+void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) {
+ model_->OnControlKeyChanged(pressed);
+}
+
void AutocompleteEditViewMac::AcceptInput(
WindowOpenDisposition disposition, bool for_drop) {
model_->AcceptInput(disposition, for_drop);
@@ -671,6 +675,16 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
return YES;
}
+ // When the user does Control-Enter, the existing content has "www."
+ // prepended and ".com" appended. |model_| should already have
+ // received notification when the Control key was depressed, but it
+ // is safe to tell it twice.
+ if (cmd == @selector(insertLineBreak:)) {
+ edit_view_->OnControlKeyChanged(true);
+ edit_view_->AcceptInput(CURRENT_TAB, false);
+ return YES;
+ }
+
// Capture the state before the operation changes the content.
// TODO(shess): Determine if this is always redundent WRT the call
// in -controlTextDidChange:.
@@ -699,6 +713,8 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
// it's set to the start of the text.
}
+// AutocompleteTextField/Editor adds a delegate method which allows us
+// to intercept and handle -paste: calls.
- (BOOL)control:(NSControl*)control textShouldPaste:(NSText*)fieldEditor {
edit_view_->OnPaste();
@@ -711,4 +727,17 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
edit_view_->OnDidResignKey();
}
+// AutocompleteTextField adds a delegate method which allows us to
+// track -flagsChanged: calls.
+//
+// When the user types Control-Enter, the existing content has "www."
+// prepended and ".com" appended. This calls down to
+// AutocompleteEditModel::OnControlKeyChanged() so that it can change
+// the popup to reflect this. See autocomplete_edit.cc
+// OnControlKeyChanged() and OnAfterPossibleChange().
+- (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent {
+ BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0;
+ edit_view_->OnControlKeyChanged(controlFlag);
+}
+
@end
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.h ('k') | chrome/browser/cocoa/autocomplete_text_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698