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

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

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 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 unified diff | Download patch | Annotate | Revision Log
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/native_textfield_win.h" 5 #include "ui/views/controls/textfield/native_textfield_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 606
607 //////////////////////////////////////////////////////////////////////////////// 607 ////////////////////////////////////////////////////////////////////////////////
608 // NativeTextfieldWin, private: 608 // NativeTextfieldWin, private:
609 609
610 void NativeTextfieldWin::OnChar(TCHAR ch, UINT repeat_count, UINT flags) { 610 void NativeTextfieldWin::OnChar(TCHAR ch, UINT repeat_count, UINT flags) {
611 HandleKeystroke(); 611 HandleKeystroke();
612 } 612 }
613 613
614 void NativeTextfieldWin::OnContextMenu(HWND window, const POINT& point) { 614 void NativeTextfieldWin::OnContextMenu(HWND window, const POINT& point) {
615 POINT p(point); 615 POINT p(point);
616 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
616 if (point.x == -1 || point.y == -1) { 617 if (point.x == -1 || point.y == -1) {
618 source_type = ui::MENU_SOURCE_KEYBOARD;
617 GetCaretPos(&p); 619 GetCaretPos(&p);
618 MapWindowPoints(HWND_DESKTOP, &p, 1); 620 MapWindowPoints(HWND_DESKTOP, &p, 1);
619 } 621 }
620 BuildContextMenu(); 622 BuildContextMenu();
621 623
622 MenuModelAdapter adapter(context_menu_contents_.get()); 624 MenuModelAdapter adapter(context_menu_contents_.get());
623 context_menu_runner_.reset(new MenuRunner(adapter.CreateMenu())); 625 context_menu_runner_.reset(new MenuRunner(adapter.CreateMenu()));
624 626
625 ignore_result(context_menu_runner_->RunMenuAt(textfield_->GetWidget(), NULL, 627 ignore_result(context_menu_runner_->RunMenuAt(textfield_->GetWidget(), NULL,
626 gfx::Rect(gfx::Point(p), gfx::Size()), MenuItemView::TOPLEFT, 628 gfx::Rect(gfx::Point(p), gfx::Size()), MenuItemView::TOPLEFT,
627 MenuRunner::HAS_MNEMONICS)); 629 source_type, MenuRunner::HAS_MNEMONICS));
628 } 630 }
629 631
630 void NativeTextfieldWin::OnCopy() { 632 void NativeTextfieldWin::OnCopy() {
631 if (textfield_->IsObscured()) 633 if (textfield_->IsObscured())
632 return; 634 return;
633 635
634 const string16 text(GetSelectedText()); 636 const string16 text(GetSelectedText());
635 if (!text.empty()) { 637 if (!text.empty()) {
636 ui::ScopedClipboardWriter( 638 ui::ScopedClipboardWriter(
637 ui::Clipboard::GetForCurrentThread(), 639 ui::Clipboard::GetForCurrentThread(),
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 return true; 1313 return true;
1312 MSG msg(*GetCurrentMessage()); 1314 MSG msg(*GetCurrentMessage());
1313 // ATL doesn't set the |time| field. 1315 // ATL doesn't set the |time| field.
1314 if (!msg.time) 1316 if (!msg.time)
1315 msg.time = GetMessageTime(); 1317 msg.time = GetMessageTime();
1316 ui::MouseEvent mouse_event(msg); 1318 ui::MouseEvent mouse_event(msg);
1317 return !controller->HandleMouseEvent(textfield_, mouse_event); 1319 return !controller->HandleMouseEvent(textfield_, mouse_event);
1318 } 1320 }
1319 1321
1320 } // namespace views 1322 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.cc ('k') | ui/views/controls/tree/tree_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698