more fixes

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17104 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-04-12 11:25:59 +00:00
parent 71960e33b9
commit 0e0b8fd554
2 changed files with 29 additions and 21 deletions

View File

@ -1146,7 +1146,6 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
bigtime_t startTime = system_time();
bigtime_t delay = 200000; // TODO: Test and reduce if needed.
bool okay = true;
while (true) {
bool locked = LockLooper();
if (!locked)
@ -1172,7 +1171,6 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
}
} else {
if (OverSuper(screenLocation)) {
okay = false;
localAction = MENU_ACT_NONE;
item = NULL;
UnlockLooper();
@ -1188,7 +1186,7 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
int submenuAction = MENU_ACT_NONE;
if (IsStickyMode())
fSelected->Submenu()->SetStickyMode(true);
BMenuItem *submenuItem = fSelected->Submenu()->_track(&submenuAction, startTime);
BMenuItem *submenuItem = fSelected->Submenu()->_track(&submenuAction, trackTime);
if (submenuAction == MENU_ACT_CLOSE) {
item = submenuItem;
localAction = submenuAction;

View File

@ -392,18 +392,27 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
ulong buttons;
GetMouse(&where, &buttons);
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
if (menuItem != NULL && menuItem != fSelected) {
if (menuItem != NULL) {
// Select item if:
// - no previous selection
// - nonsticky mode and different selection,
// - clicked in sticky mode
// - nonsticky mode,
// - no previous selection
if (fSelected == NULL || !IsStickyMode() || buttons != 0) {
// only select the item
SelectItem(menuItem, -1);
if (menuItem->Submenu() != NULL
&& menuItem->Submenu()->Window() == NULL) {
// open the menu if it's not opened yet
SelectItem(menuItem);
if (fSelected == NULL
|| (!IsStickyMode() && menuItem != fSelected)
|| (buttons != 0 && IsStickyMode())) {
if (menuItem->Submenu() != NULL) {
if (menuItem->Submenu()->Window() == NULL) {
// open the menu if it's not opened yet
SelectItem(menuItem);
} else {
// Menu was already opened, close it and bail
SelectItem(NULL);
localAction = MENU_ACT_CLOSE;
resultItem = NULL;
}
} else {
// No submenu, just select the item
SelectItem(menuItem);
}
}
}
@ -429,11 +438,15 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (localAction == MENU_ACT_CLOSE || (buttons != 0 && IsStickyMode() && menuItem == NULL))
break;
else if (buttons == 0 && !IsStickyMode()) {
// Don't switch to sticky mode if user kept the mouse pressed for too long
// TODO: Delay could be smaller, but then it wouldn't be noticeable on QEMU on my machine
if (IsStickyPrefOn() && system_time() < startTime + 2000000)
// On an item without a submenu
if (fSelected != NULL && fSelected->Submenu() == NULL) {
resultItem = fSelected;
break;
} else if (IsStickyPrefOn() && system_time() < startTime + 2000000) {
// Don't switch to sticky mode if user kept the mouse pressed for too long
// TODO: Delay could be smaller, but then it wouldn't be noticeable on QEMU on my machine
SetStickyMode(true);
else
} else
break;
}
@ -442,11 +455,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
}
if (window->Lock()) {
if (fSelected != NULL) {
if (fSelected->Submenu() == NULL)
resultItem = fSelected;
if (fSelected != NULL)
SelectItem(NULL);
}
if (resultItem != NULL)
resultItem->Invoke();
window->Unlock();