Added a small time hysteresis: submenus are only opened if the user keeps the mouse there for a while. I'd like feedback on this
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16015 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1108,17 +1108,31 @@ BMenu::_track(int *action, long start)
|
|||||||
ulong buttons;
|
ulong buttons;
|
||||||
BMenuItem *item = NULL;
|
BMenuItem *item = NULL;
|
||||||
int localAction = MENU_ACT_NONE;
|
int localAction = MENU_ACT_NONE;
|
||||||
|
|
||||||
|
bigtime_t startTime = system_time();
|
||||||
|
bigtime_t clickTime = 0;
|
||||||
|
get_click_speed(&clickTime);
|
||||||
do {
|
do {
|
||||||
if (!LockLooper())
|
if (!LockLooper())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
bigtime_t snoozeAmount = 50000;
|
||||||
BPoint location;
|
BPoint location;
|
||||||
GetMouse(&location, &buttons);
|
GetMouse(&location, &buttons);
|
||||||
|
|
||||||
item = HitTestItems(location, B_ORIGIN);
|
item = HitTestItems(location, B_ORIGIN);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
if (item != fSelected)
|
if (item != fSelected) {
|
||||||
|
SelectItem(item, -1);
|
||||||
|
startTime = system_time();
|
||||||
|
snoozeAmount = 20000;
|
||||||
|
} else if (system_time() > clickTime + startTime && item->Submenu()
|
||||||
|
&& item->Submenu()->Window() == NULL) {
|
||||||
|
// Open the submenu if it's not opened yet, but only if
|
||||||
|
// the mouse pointer stayed over there for some time
|
||||||
|
// (hysteresis)
|
||||||
SelectItem(item);
|
SelectItem(item);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (OverSuper(location)) {
|
if (OverSuper(location)) {
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
@@ -1128,7 +1142,8 @@ BMenu::_track(int *action, long start)
|
|||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fSelected != NULL && fSelected->Submenu() != NULL) {
|
if (fSelected != NULL && fSelected->Submenu() != NULL
|
||||||
|
&& fSelected->Submenu()->Window() != NULL) {
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
|
|
||||||
int submenuAction = MENU_ACT_NONE;
|
int submenuAction = MENU_ACT_NONE;
|
||||||
@@ -1145,7 +1160,7 @@ BMenu::_track(int *action, long start)
|
|||||||
|
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
|
|
||||||
snooze(50000);
|
snooze(snoozeAmount);
|
||||||
} while (buttons != 0);
|
} while (buttons != 0);
|
||||||
|
|
||||||
if (localAction == MENU_ACT_NONE) {
|
if (localAction == MENU_ACT_NONE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user