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

Unified Diff: ui/views/controls/menu/menu_host.cc

Issue 378333003: Allow menus to stay open during a child view's drag and drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test Fix Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/menu/menu_host.h ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_host.cc
diff --git a/ui/views/controls/menu/menu_host.cc b/ui/views/controls/menu/menu_host.cc
index 2716ec8bb782c1a46288c0ab449d80a2a96e2caf..3a8217f55485fef566d69f9ebb05ca28dab60a67 100644
--- a/ui/views/controls/menu/menu_host.cc
+++ b/ui/views/controls/menu/menu_host.cc
@@ -135,4 +135,34 @@ void MenuHost::OnOwnerClosing() {
menu_controller->CancelAll();
}
+void MenuHost::OnDragWillStart() {
+ MenuController* menu_controller =
+ submenu_->GetMenuItem()->GetMenuController();
+ DCHECK(menu_controller);
+ menu_controller->OnDragWillStart();
+}
+
+void MenuHost::OnDragComplete() {
+ MenuController* menu_controller =
+ submenu_->GetMenuItem()->GetMenuController();
+ if (destroying_ || !menu_controller)
+ return;
+
+ bool should_close = true;
+ // If the view came from outside menu code (i.e., not a MenuItemView), we
+ // should consult the MenuDelegate to determine whether or not to close on
+ // exit.
+ if (!menu_controller->did_initiate_drag()) {
+ MenuDelegate* menu_delegate = submenu_->GetMenuItem()->GetDelegate();
+ should_close =
+ menu_delegate ? menu_delegate->ShouldCloseOnDragComplete() : should_close;
+ }
+ menu_controller->OnDragComplete(should_close);
+
+ // We may have lost capture in the drag and drop, but are remaining open.
+ // Return capture so we get MouseCaptureLost events.
+ if (!should_close)
+ native_widget_private()->SetCapture();
+}
+
} // namespace views
« no previous file with comments | « ui/views/controls/menu/menu_host.h ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698