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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 2164483006: [MacViews] Implemented text context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ditto Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 context_menu_contents_.reset(new ui::SimpleMenuModel(this)); 1909 context_menu_contents_.reset(new ui::SimpleMenuModel(this));
1910 context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO); 1910 context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO);
1911 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); 1911 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
1912 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); 1912 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT);
1913 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1913 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1914 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); 1914 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE);
1915 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE); 1915 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE);
1916 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); 1916 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
1917 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, 1917 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL,
1918 IDS_APP_SELECT_ALL); 1918 IDS_APP_SELECT_ALL);
1919 if (!text_context_menu_.get()) {
tapted 2016/07/22 03:06:42 this `if` check shouldn't be needed..
spqchan 2016/12/12 19:32:27 Done.
1920 text_context_menu_.reset(ViewsTextContextMenu::Create(this));
1921 text_context_menu_->UpdateContextMenu(context_menu_contents_.get());
tapted 2016/07/22 03:06:42 but there should be a check before this to ensure
spqchan 2016/12/12 19:32:27 Removed text_context_menu_
1922 }
1919 1923
1920 // If the controller adds menu commands, also override ExecuteCommand() and 1924 // If the controller adds menu commands, also override ExecuteCommand() and
1921 // IsCommandIdEnabled() as appropriate, for the commands added. 1925 // IsCommandIdEnabled() as appropriate, for the commands added.
1922 if (controller_) 1926 if (controller_)
1923 controller_->UpdateContextMenu(context_menu_contents_.get()); 1927 controller_->UpdateContextMenu(context_menu_contents_.get());
1924 } 1928 }
1929
1925 context_menu_runner_.reset( 1930 context_menu_runner_.reset(
1926 new MenuRunner(context_menu_contents_.get(), 1931 new MenuRunner(context_menu_contents_.get(),
1927 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU)); 1932 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU));
1928 } 1933 }
1929 1934
1930 void Textfield::TrackMouseClicks(const ui::MouseEvent& event) { 1935 void Textfield::TrackMouseClicks(const ui::MouseEvent& event) {
1931 if (event.IsOnlyLeftMouseButton()) { 1936 if (event.IsOnlyLeftMouseButton()) {
1932 base::TimeDelta time_delta = event.time_stamp() - last_click_time_; 1937 base::TimeDelta time_delta = event.time_stamp() - last_click_time_;
1933 if (time_delta.InMilliseconds() <= GetDoubleClickInterval() && 1938 if (time_delta.InMilliseconds() <= GetDoubleClickInterval() &&
1934 !ExceededDragThreshold(event.location() - last_click_location_)) { 1939 !ExceededDragThreshold(event.location() - last_click_location_)) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 RequestFocus(); 2000 RequestFocus();
1996 model_->MoveCursorTo(mouse); 2001 model_->MoveCursorTo(mouse);
1997 if (!selection_clipboard_text.empty()) { 2002 if (!selection_clipboard_text.empty()) {
1998 model_->InsertText(selection_clipboard_text); 2003 model_->InsertText(selection_clipboard_text);
1999 UpdateAfterChange(true, true); 2004 UpdateAfterChange(true, true);
2000 } 2005 }
2001 OnAfterUserAction(); 2006 OnAfterUserAction();
2002 } 2007 }
2003 2008
2004 } // namespace views 2009 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698