From f356aedc02c9128eb7ede409e796e885ab5c8825 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 27 Mar 2006 19:43:05 +0000 Subject: [PATCH] Implemented BMenu::OkToProceed() and used it correctly in BMenu::AttachedToWindow(). For some reason, though, I had to comment it out partially as something is wrong. I haven't debugged, though git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16899 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index b301d231c7..55b5e04eae 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -7,6 +7,7 @@ * Stefano Ceccherini (burton666@libero.it) */ +#include #include #include @@ -264,9 +265,11 @@ BMenu::AttachedToWindow() free(chars); free(keys); + BMenuItem *superItem = Superitem(); + BMenu *superMenu = Supermenu(); if (AddDynamicItem(B_INITIAL_ADD)) { do { - if (!OkToProceed(NULL)) { + if (superMenu != NULL && !superMenu->OkToProceed(superItem)) { AddDynamicItem(B_ABORT); fAttachAborted = true; break; @@ -1873,10 +1876,19 @@ BMenu::RedrawAfterSticky(BRect bounds) bool BMenu::OkToProceed(BMenuItem* item) { - // ToDo: test if the window could be closed again already - - // ToDo: for now - return true; + bool proceed = true; + BPoint where; + ulong buttons; + GetMouse(&where, &buttons, false); + ConvertToScreen(&where); + + // Quit if user releases the mouse button or moves + // the pointer over another item + // TODO: For some reason, this doesn't work + if (buttons == 0 /*|| HitTestItems(where) != item*/) + proceed = false; + + return proceed; }