diff options
-rw-r--r-- | chrome/browser/views/bookmark_manager_view.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_manager_view.h | 1 | ||||
-rw-r--r-- | views/controls/table/table_view.cc | 18 | ||||
-rw-r--r-- | views/controls/table/table_view.h | 6 |
4 files changed, 38 insertions, 0 deletions
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc index 25cddc0..a66c105 100644 --- a/chrome/browser/views/bookmark_manager_view.cc +++ b/chrome/browser/views/bookmark_manager_view.cc @@ -347,6 +347,19 @@ void BookmarkManagerView::OnDoubleClick() { GetWidget()->GetNativeView(), profile_, NULL, nodes, CURRENT_TAB); } +void BookmarkManagerView::OnMiddleClick() { + std::vector<BookmarkNode*> nodes = GetSelectedTableNodes(); + if (nodes.empty()) + return; + if (nodes.size() == 1 && nodes[0]->is_folder()) { + // Middle clicking on a folder results in no action. + return; + } + + bookmark_utils::OpenAll( + GetWidget()->GetNativeView(), profile_, NULL, nodes, NEW_FOREGROUND_TAB); +} + void BookmarkManagerView::OnTableViewDelete(views::TableView* table) { std::vector<BookmarkNode*> nodes = GetSelectedTableNodes(); if (nodes.empty()) diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h index 3c73375..710363a 100644 --- a/chrome/browser/views/bookmark_manager_view.h +++ b/chrome/browser/views/bookmark_manager_view.h @@ -98,6 +98,7 @@ class BookmarkManagerView : public views::View, virtual void OnSelectionChanged() {} // Overriden to open the selected table nodes in the current browser. virtual void OnDoubleClick(); + virtual void OnMiddleClick(); virtual void OnTableViewDelete(views::TableView* table); virtual void OnKeyDown(unsigned short virtual_keycode); diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index da4aeb04..5650f9f 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -649,6 +649,19 @@ LRESULT CALLBACK TableView::TableWndProc(HWND window, return 0; } + case WM_MBUTTONDOWN: { + if (w_param == MK_MBUTTON) { + int view_index = GetViewIndexFromMouseEvent(window, l_param); + if (view_index != -1) { + int model_index = table_view->view_to_model(view_index); + // Clear all and select the row that was middle clicked. + table_view->Select(model_index); + table_view->OnMiddleClick(); + } + } + return 0; + } + case WM_LBUTTONUP: { if (in_mouse_down) { in_mouse_down = false; @@ -1478,6 +1491,11 @@ void TableView::OnDoubleClick() { } } +void TableView::OnMiddleClick() { + if (!ignore_listview_change_ && table_view_observer_) + table_view_observer_->OnMiddleClick(); +} + void TableView::OnSelectedStateChanged() { if (!ignore_listview_change_ && table_view_observer_) { table_view_observer_->OnSelectionChanged(); diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h index da228fc..c1a9a23 100644 --- a/views/controls/table/table_view.h +++ b/views/controls/table/table_view.h @@ -284,6 +284,9 @@ class TableViewObserver { // Optional method invoked when the user double clicks on the table. virtual void OnDoubleClick() {} + // Optional method invoked when the user middle clicks on the table. + virtual void OnMiddleClick() {} + // Optional method invoked when the user hits a key with the table in focus. virtual void OnKeyDown(unsigned short virtual_keycode) {} @@ -452,6 +455,9 @@ class TableView : public NativeControl, // Notification from the ListView that the used double clicked the table. virtual void OnDoubleClick(); + // Notification from the ListView that the user middle clicked the table. + virtual void OnMiddleClick(); + // Subclasses can implement this method if they need to be notified of a key // press event. Other wise, it appeals to table_view_observer_ virtual void OnKeyDown(unsigned short virtual_keycode); |