0

Middle clicking on a bookmark from the bookmark manager now

opens that bookmark in a new foreground tab.

http://crbug.com/7788
Checked in for Meelap Shah
Original review = http://codereview.chromium.org/115665

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16760 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
brettw@google.com
2009-05-22 18:15:16 +00:00
parent 0f92d1d1ac
commit 03ce2f5bf3
4 changed files with 38 additions and 0 deletions

@ -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())

@ -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);

@ -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();

@ -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);