From f71910c068ed509205ba27d988ef695b8956ea37 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Fri, 28 Jan 2011 05:31:40 +0000 Subject: [PATCH] Apply the patch from Pete Goodeve from #7165 and therefore fix that ticket. Instead of forcing a click to open rect this just restarts menu tracking if the mouse was clicked. It seems to work great and is cleaner than my solution which is removed in this commit as well. This still fixes the problem of accidentially selecting menu items but also maintains the API. Good job Pete! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40306 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/PopUpMenu.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/kits/interface/PopUpMenu.cpp b/src/kits/interface/PopUpMenu.cpp index 527d0e23cc..c9e5cf43d5 100644 --- a/src/kits/interface/PopUpMenu.cpp +++ b/src/kits/interface/PopUpMenu.cpp @@ -317,18 +317,6 @@ BMenuItem * BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened, BRect *_specialRect, bool async) { - // Force start opened. This is just better behavior. - startOpened = true; - - BRect clickToOpenRect; - - // If no click to open rect was provided make one around the opening - // point. - if (startOpened && _specialRect == NULL) { - clickToOpenRect.Set(where.x, where.y, where.x, where.y); - clickToOpenRect.InsetBy(-2, -2); - _specialRect = &clickToOpenRect; - } if (fTrackThread >= B_OK) { // we already have an active menu, wait for it to go away before @@ -430,10 +418,19 @@ BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened, BRect * // called by BMenu::Track() fUseWhere = true; + // Determine when mouse-down-up will be taken as a 'press', rather than a 'click' + bigtime_t clickMaxTime = 0; + get_click_speed(&clickMaxTime); + clickMaxTime += system_time(); + // Show the menu's window Show(); snooze(50000); BMenuItem *result = Track(startOpened, _specialRect); + + // If it was a click, keep the menu open and tracking + if (system_time() <= clickMaxTime) + result = Track(true, _specialRect); if (result != NULL && autoInvoke) result->Invoke();