Added a short delay to item unhighlighting when using key. eqs. and

some corrections to submenu attaching.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5229 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
dlazaro 1999-11-17 23:01:54 +00:00
parent 35ec3ff7e0
commit cf28787fa7
3 changed files with 50 additions and 18 deletions

View file

@ -1,3 +1,11 @@
1999-11-18 David Lazaro Saz <khelekir@encomix.es>
* Source/NSMenuView.m ([NSMenuView
-performActionWithHighlightingForItemAtIndex:]): Added a short delay to
item unhiglighting (100ms).
([NSMenuView -trackWithEvent:]): When an attached menu is present other
items only highlight when the cursor stops at them.
1999-11-17 David Lazaro Saz <khelekir@encomix.es> 1999-11-17 David Lazaro Saz <khelekir@encomix.es>
* Source/NSWindow.m ([NSWindow -setLevel:]): * Source/NSWindow.m ([NSWindow -setLevel:]):

View file

@ -1147,7 +1147,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
} }
} }
#define SHIFT_DELTA 15.0 #define SHIFT_DELTA 18.0
- (void) shiftOnScreen - (void) shiftOnScreen
{ {

View file

@ -670,9 +670,12 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
[menuv_menu performActionForItemAtIndex: index]; [menuv_menu performActionForItemAtIndex: index];
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
[targetMenuView setHighlightedItemIndex: -1]; [targetMenuView setHighlightedItemIndex: -1];
} }
#define MOVE_THRESHOLD_DELTA 1
- (BOOL)trackWithEvent: (NSEvent *)event - (BOOL)trackWithEvent: (NSEvent *)event
{ {
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
@ -681,25 +684,31 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
| NSPeriodicMask; | NSPeriodicMask;
NSDate *theDistantFuture = [NSDate distantFuture]; NSDate *theDistantFuture = [NSDate distantFuture];
NSPoint location;
int index; int index;
NSPoint location;
NSPoint lastLocation = {0,0};
NSMenu *alreadyAttachedMenu = NO; NSMenu *alreadyAttachedMenu = NO;
BOOL delayedSelect = NO;
do do
{ {
location = [window mouseLocationOutsideOfEventStream]; location = [window mouseLocationOutsideOfEventStream];
index = [self indexOfItemAtPoint: location]; index = [self indexOfItemAtPoint: location];
if ([event type] == NSPeriodic) if ([event type] == NSPeriodic)
if ([menuv_menu isPartlyOffScreen]) {
{ if ([menuv_menu isPartlyOffScreen])
NSPoint pointerLoc = [window convertBaseToScreen: location]; {
NSPoint pointerLoc = [window convertBaseToScreen:
location];
// TODO: Why 1 in the Y axis? // TODO: Why 1 in the Y axis?
if (pointerLoc.x == 0 || pointerLoc.y == 1 || if (pointerLoc.x == 0 || pointerLoc.y == 1 ||
pointerLoc.x == [[window screen] frame].size.width - 1) pointerLoc.x == [[window screen] frame].size.width
[menuv_menu shiftOnScreen]; - 1)
} [menuv_menu shiftOnScreen];
}
}
if (index == -1) if (index == -1)
{ {
@ -722,14 +731,29 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
{ {
if (index != menuv_highlightedItemIndex) if (index != menuv_highlightedItemIndex)
{ {
[self setHighlightedItemIndex: index]; if ([event type] == NSPeriodic && delayedSelect)
{
if (location.x - lastLocation.x < MOVE_THRESHOLD_DELTA ||
abs(location.y - lastLocation.y) < MOVE_THRESHOLD_DELTA)
delayedSelect = NO;
if ([menuv_menu attachedMenu]) lastLocation = location;
[self detachSubmenu]; }
if ((alreadyAttachedMenu = if (![menuv_menu attachedMenu] || !delayedSelect)
[[menuv_items_link objectAtIndex: index] submenu])) {
[self attachSubmenuForItemAtIndex: index]; [self setHighlightedItemIndex: index];
if ([menuv_menu attachedMenu])
[self detachSubmenu];
if ((alreadyAttachedMenu =
[[menuv_items_link objectAtIndex: index] submenu]))
{
[self attachSubmenuForItemAtIndex: index];
delayedSelect = YES;
}
}
} }
} }