OLD | NEW |
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 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 GetInputMethod()->CancelComposition(this); | 980 GetInputMethod()->CancelComposition(this); |
981 } | 981 } |
982 | 982 |
983 //////////////////////////////////////////////////////////////////////////////// | 983 //////////////////////////////////////////////////////////////////////////////// |
984 // Textfield, ContextMenuController overrides: | 984 // Textfield, ContextMenuController overrides: |
985 | 985 |
986 void Textfield::ShowContextMenuForView(View* source, | 986 void Textfield::ShowContextMenuForView(View* source, |
987 const gfx::Point& point, | 987 const gfx::Point& point, |
988 ui::MenuSourceType source_type) { | 988 ui::MenuSourceType source_type) { |
989 UpdateContextMenu(); | 989 UpdateContextMenu(); |
990 ignore_result(context_menu_runner_->RunMenuAt( | 990 ignore_result(context_menu_runner_->RunMenuAt(GetWidget(), |
991 GetWidget(), | 991 NULL, |
992 NULL, | 992 gfx::Rect(point, gfx::Size()), |
993 gfx::Rect(point, gfx::Size()), | 993 MENU_ANCHOR_TOPLEFT, |
994 MENU_ANCHOR_TOPLEFT, | 994 source_type)); |
995 source_type, | |
996 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU)); | |
997 } | 995 } |
998 | 996 |
999 //////////////////////////////////////////////////////////////////////////////// | 997 //////////////////////////////////////////////////////////////////////////////// |
1000 // Textfield, DragController overrides: | 998 // Textfield, DragController overrides: |
1001 | 999 |
1002 void Textfield::WriteDragDataForView(View* sender, | 1000 void Textfield::WriteDragDataForView(View* sender, |
1003 const gfx::Point& press_pt, | 1001 const gfx::Point& press_pt, |
1004 OSExchangeData* data) { | 1002 OSExchangeData* data) { |
1005 const base::string16& selected_text(GetSelectedText()); | 1003 const base::string16& selected_text(GetSelectedText()); |
1006 data->SetString(selected_text); | 1004 data->SetString(selected_text); |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); | 1694 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); |
1697 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); | 1695 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); |
1698 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); | 1696 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); |
1699 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE); | 1697 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE); |
1700 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); | 1698 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
1701 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, | 1699 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, |
1702 IDS_APP_SELECT_ALL); | 1700 IDS_APP_SELECT_ALL); |
1703 if (controller_) | 1701 if (controller_) |
1704 controller_->UpdateContextMenu(context_menu_contents_.get()); | 1702 controller_->UpdateContextMenu(context_menu_contents_.get()); |
1705 } | 1703 } |
1706 context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get())); | 1704 context_menu_runner_.reset( |
| 1705 new MenuRunner(context_menu_contents_.get(), |
| 1706 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU)); |
1707 } | 1707 } |
1708 | 1708 |
1709 void Textfield::TrackMouseClicks(const ui::MouseEvent& event) { | 1709 void Textfield::TrackMouseClicks(const ui::MouseEvent& event) { |
1710 if (event.IsOnlyLeftMouseButton()) { | 1710 if (event.IsOnlyLeftMouseButton()) { |
1711 base::TimeDelta time_delta = event.time_stamp() - last_click_time_; | 1711 base::TimeDelta time_delta = event.time_stamp() - last_click_time_; |
1712 if (time_delta.InMilliseconds() <= GetDoubleClickInterval() && | 1712 if (time_delta.InMilliseconds() <= GetDoubleClickInterval() && |
1713 !ExceededDragThreshold(event.location() - last_click_location_)) { | 1713 !ExceededDragThreshold(event.location() - last_click_location_)) { |
1714 // Upon clicking after a triple click, the count should go back to double | 1714 // Upon clicking after a triple click, the count should go back to double |
1715 // click and alternate between double and triple. This assignment maps | 1715 // click and alternate between double and triple. This assignment maps |
1716 // 0 to 1, 1 to 2, 2 to 1. | 1716 // 0 to 1, 1 to 2, 2 to 1. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1778 const size_t length = selection_clipboard_text.length(); | 1778 const size_t length = selection_clipboard_text.length(); |
1779 range = gfx::Range(range.start() + length, range.end() + length); | 1779 range = gfx::Range(range.start() + length, range.end() + length); |
1780 } | 1780 } |
1781 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); | 1781 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); |
1782 UpdateAfterChange(true, true); | 1782 UpdateAfterChange(true, true); |
1783 OnAfterUserAction(); | 1783 OnAfterUserAction(); |
1784 } | 1784 } |
1785 } | 1785 } |
1786 | 1786 |
1787 } // namespace views | 1787 } // namespace views |
OLD | NEW |