mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Tidyup.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4528 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a5a733ed2
commit
e45769ccb0
2 changed files with 274 additions and 225 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Jul 6 16:55:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* NSMenuView.m: In ([-trackWithEvent:]) fixed indexing bug when mouse
|
||||
dragged off bottom of menu and released, also reformatted to GNU
|
||||
coding style.
|
||||
|
||||
Tue Jul 6 14:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Headers/AppKit/NSAffineTransform.h: Removed macros
|
||||
|
|
|
@ -15,7 +15,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return GSMenuBarHeight;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
||||
- (BOOL)acceptsFirstMouse: (NSEvent *)theEvent
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
@ -24,20 +24,20 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithFrame:NSZeroRect];
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)aFrame
|
||||
- (id)initWithFrame: (NSRect)aFrame
|
||||
{
|
||||
cellSize = NSMakeSize(110,20);
|
||||
menuv_highlightedItemIndex = -1;
|
||||
|
||||
return [super initWithFrame:aFrame];
|
||||
return [super initWithFrame: aFrame];
|
||||
}
|
||||
|
||||
// Our menu.
|
||||
|
||||
- (void)setMenu:(NSMenu *)menu
|
||||
- (void)setMenu: (NSMenu *)menu
|
||||
{
|
||||
ASSIGN(menuv_menu, menu);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return menuv_menu;
|
||||
}
|
||||
|
||||
- (void)setHorizontal:(BOOL)flag
|
||||
- (void)setHorizontal: (BOOL)flag
|
||||
{
|
||||
menuv_horizontal = flag;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return menuv_horizontal;
|
||||
}
|
||||
|
||||
- (void)setFont:(NSFont *)font
|
||||
- (void)setFont: (NSFont *)font
|
||||
{
|
||||
ASSIGN(menuv_font, font);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
}
|
||||
|
||||
/*
|
||||
* - (void)setHighlightedItemIndex:(int)index
|
||||
* - (void)setHighlightedItemIndex: (int)index
|
||||
*
|
||||
* MacOS-X defines this function as the central way of switching to a new
|
||||
* highlighted item. The index value is == to the item you want
|
||||
|
@ -76,7 +76,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
* applicable) and selects the new item. If index == -1 highlighting is
|
||||
* turned off.
|
||||
*
|
||||
* NOTES (Michael Hanni):
|
||||
* NOTES (Michael Hanni):
|
||||
*
|
||||
* I modified this method for GNUstep to take submenus into account. This
|
||||
* way we get maximum performance while still using a method outside the
|
||||
|
@ -84,7 +84,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
*
|
||||
*/
|
||||
|
||||
- (void)setHighlightedItemIndex:(int)index
|
||||
- (void)setHighlightedItemIndex: (int)index
|
||||
{
|
||||
NSArray *menu_items = [menuv_menu itemArray];
|
||||
id anItem;
|
||||
|
@ -94,36 +94,36 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
|
||||
if (index == -1) {
|
||||
if (menuv_highlightedItemIndex != -1) {
|
||||
anItem = [menu_items objectAtIndex:menuv_highlightedItemIndex];
|
||||
anItem = [menu_items objectAtIndex: menuv_highlightedItemIndex];
|
||||
|
||||
[anItem highlight:NO
|
||||
withFrame:[self rectOfItemAtIndex:menuv_highlightedItemIndex]
|
||||
inView:self];
|
||||
[anItem setState:0];
|
||||
[anItem highlight: NO
|
||||
withFrame: [self rectOfItemAtIndex: menuv_highlightedItemIndex]
|
||||
inView: self];
|
||||
[anItem setState: 0];
|
||||
menuv_highlightedItemIndex = -1;
|
||||
}
|
||||
} else if (index >= 0) {
|
||||
if ( menuv_highlightedItemIndex != -1 ) {
|
||||
anItem = [menu_items objectAtIndex:menuv_highlightedItemIndex];
|
||||
anItem = [menu_items objectAtIndex: menuv_highlightedItemIndex];
|
||||
|
||||
[anItem highlight:NO
|
||||
withFrame:[self rectOfItemAtIndex:menuv_highlightedItemIndex]
|
||||
inView:self];
|
||||
[anItem highlight: NO
|
||||
withFrame: [self rectOfItemAtIndex: menuv_highlightedItemIndex]
|
||||
inView: self];
|
||||
|
||||
if ([anItem hasSubmenu] && ![[anItem target] isTornOff])
|
||||
[[anItem target] close];
|
||||
|
||||
[anItem setState:0];
|
||||
[anItem setState: 0];
|
||||
}
|
||||
|
||||
if (menuv_highlightedItemIndex != index) {
|
||||
anItem = [menu_items objectAtIndex:index];
|
||||
anItem = [menu_items objectAtIndex: index];
|
||||
|
||||
[anItem highlight:YES
|
||||
withFrame:[self rectOfItemAtIndex:index]
|
||||
inView:self];
|
||||
[anItem highlight: YES
|
||||
withFrame: [self rectOfItemAtIndex: index]
|
||||
inView: self];
|
||||
|
||||
[anItem setState:1];
|
||||
[anItem setState: 1];
|
||||
|
||||
if ([anItem hasSubmenu])
|
||||
[[anItem target] display];
|
||||
|
@ -146,21 +146,21 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return menuv_highlightedItemIndex;
|
||||
}
|
||||
|
||||
- (void)setMenuItemCell:(NSMenuItemCell *)cell
|
||||
forItemAtIndex:(int)index
|
||||
- (void)setMenuItemCell: (NSMenuItemCell *)cell
|
||||
forItemAtIndex: (int)index
|
||||
{
|
||||
// [menuv_items insertObject:cell atIndex:index];
|
||||
// [menuv_items insertObject: cell atIndex: index];
|
||||
|
||||
// resize the cell
|
||||
[cell setNeedsSizing:YES];
|
||||
[cell setNeedsSizing: YES];
|
||||
|
||||
// resize menuview
|
||||
[self setNeedsSizing:YES];
|
||||
[self setNeedsSizing: YES];
|
||||
}
|
||||
|
||||
- (NSMenuItemCell *)menuItemCellForItemAtIndex:(int)index
|
||||
- (NSMenuItemCell *)menuItemCellForItemAtIndex: (int)index
|
||||
{
|
||||
return [[menuv_menu itemArray] objectAtIndex:index];
|
||||
return [[menuv_menu itemArray] objectAtIndex: index];
|
||||
}
|
||||
|
||||
- (NSMenuView *)attachedMenuView
|
||||
|
@ -183,7 +183,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return [menuv_menu isTornOff];
|
||||
}
|
||||
|
||||
- (void)setHorizontalEdgePadding:(float)pad
|
||||
- (void)setHorizontalEdgePadding: (float)pad
|
||||
{
|
||||
menuv_hEdgePad = pad;
|
||||
}
|
||||
|
@ -193,15 +193,15 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return menuv_hEdgePad;
|
||||
}
|
||||
|
||||
- (void)itemChanged:(NSNotification *)notification
|
||||
- (void)itemChanged: (NSNotification *)notification
|
||||
{
|
||||
}
|
||||
|
||||
- (void)itemAdded:(NSNotification *)notification
|
||||
- (void)itemAdded: (NSNotification *)notification
|
||||
{
|
||||
}
|
||||
|
||||
- (void)itemRemoved:(NSNotification *)notification
|
||||
- (void)itemRemoved: (NSNotification *)notification
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
{
|
||||
}
|
||||
|
||||
- (void)attachSubmenuForItemAtIndex:(int)index
|
||||
- (void)attachSubmenuForItemAtIndex: (int)index
|
||||
{
|
||||
// create rect to display submenu in.
|
||||
|
||||
|
@ -226,7 +226,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
[self sizeToFit];
|
||||
}
|
||||
|
||||
- (void)setNeedsSizing:(BOOL)flag
|
||||
- (void)setNeedsSizing: (BOOL)flag
|
||||
{
|
||||
menuv_needsSizing = flag;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
{
|
||||
float aWidth;
|
||||
|
||||
NSMenuItemCell *anItem = [[menuv_menu itemArray] objectAtIndex:i];
|
||||
NSMenuItemCell *anItem = [[menuv_menu itemArray] objectAtIndex: i];
|
||||
aWidth = [anItem titleWidth];
|
||||
|
||||
if (aWidth > neededWidth)
|
||||
|
@ -256,8 +256,8 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
|
||||
cellSize.width = 7 + neededWidth + 7 + 7 + 5;
|
||||
|
||||
[[self window] setFrame:NSMakeRect(300,300,cellSize.width,howHigh) display:YES];
|
||||
[self setFrame:NSMakeRect(0,0,cellSize.width,howHigh-21)];
|
||||
[[self window] setFrame: NSMakeRect(300,300,cellSize.width,howHigh) display: YES];
|
||||
[self setFrame: NSMakeRect(0,0,cellSize.width,howHigh-21)];
|
||||
}
|
||||
|
||||
- (float)stateImageOffset
|
||||
|
@ -317,7 +317,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
// you would like to see this configurable.
|
||||
}
|
||||
|
||||
- (NSRect)rectOfItemAtIndex:(int)index
|
||||
- (NSRect)rectOfItemAtIndex: (int)index
|
||||
{
|
||||
NSRect theRect;
|
||||
|
||||
|
@ -334,23 +334,23 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return theRect;
|
||||
}
|
||||
|
||||
- (int)indexOfItemAtPoint:(NSPoint)point
|
||||
- (int)indexOfItemAtPoint: (NSPoint)point
|
||||
{
|
||||
// The MacOSX API says that this method calls - rectOfItemAtIndex for
|
||||
// *every* cell to figure this out. Well, instead we will just do some
|
||||
// simple math.
|
||||
NSRect aRect = [self rectOfItemAtIndex:0];
|
||||
NSRect aRect = [self rectOfItemAtIndex: 0];
|
||||
|
||||
// this will need some finnessing but should be close.
|
||||
return ([self frame].size.height - point.y) / aRect.size.height;
|
||||
}
|
||||
|
||||
- (void)setNeedsDisplayForItemAtIndex:(int)index
|
||||
- (void)setNeedsDisplayForItemAtIndex: (int)index
|
||||
{
|
||||
[[[menuv_menu itemArray] objectAtIndex:index] setNeedsDisplay:YES];
|
||||
[[[menuv_menu itemArray] objectAtIndex: index] setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (NSPoint)locationForSubmenu:(NSMenu *)aSubmenu
|
||||
- (NSPoint)locationForSubmenu: (NSMenu *)aSubmenu
|
||||
{
|
||||
if (menuv_needsSizing)
|
||||
[self sizeToFit];
|
||||
|
@ -363,22 +363,22 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (void)resizeWindowWithMaxHeight:(float)maxHeight
|
||||
- (void)resizeWindowWithMaxHeight: (float)maxHeight
|
||||
{
|
||||
// set the menuview's window to max height in order to keep on screen?
|
||||
}
|
||||
|
||||
- (void)setWindowFrameForAttachingToRect:(NSRect)screenRect
|
||||
onScreen:(NSScreen *)screen
|
||||
preferredEdge:(NSRectEdge)edge
|
||||
popUpSelectedItem:(int)selectedItemIndex
|
||||
- (void)setWindowFrameForAttachingToRect: (NSRect)screenRect
|
||||
onScreen: (NSScreen *)screen
|
||||
preferredEdge: (NSRectEdge)edge
|
||||
popUpSelectedItem: (int)selectedItemIndex
|
||||
{
|
||||
// huh.
|
||||
}
|
||||
|
||||
// Drawing.
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
- (void)drawRect: (NSRect)rect
|
||||
{
|
||||
int i;
|
||||
NSArray *menuCells = [menuv_menu itemArray];
|
||||
|
@ -392,21 +392,21 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
|
||||
for (i=0;i<[menuCells count];i++)
|
||||
{
|
||||
id aCell = [menuCells objectAtIndex:i];
|
||||
id aCell = [menuCells objectAtIndex: i];
|
||||
|
||||
[aCell drawWithFrame:aRect inView:self];
|
||||
[aCell drawWithFrame: aRect inView: self];
|
||||
aRect.origin.y -= cellSize.height;
|
||||
}
|
||||
}
|
||||
|
||||
// Event.
|
||||
|
||||
- (void)performActionWithHighlightingForItemAtIndex:(int)index
|
||||
- (void)performActionWithHighlightingForItemAtIndex: (int)index
|
||||
{
|
||||
// for use with key equivalents.
|
||||
}
|
||||
|
||||
- (BOOL)trackWithEvent:(NSEvent *)event
|
||||
- (BOOL)trackWithEvent: (NSEvent *)event
|
||||
{
|
||||
NSPoint lastLocation = [event locationInWindow];
|
||||
float height = [self frame].size.height;
|
||||
|
@ -434,193 +434,236 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
|
||||
index = (height - lastLocation.y) / cellSize.height;
|
||||
|
||||
if (index >= 0 && index < theCount) {
|
||||
[self setHighlightedItemIndex:index];
|
||||
lastIndex = index;
|
||||
}
|
||||
|
||||
while (!done) {
|
||||
|
||||
event = [theApp nextEventMatchingMask: eventMask
|
||||
untilDate: theDistantFuture
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
switch ([event type])
|
||||
if (index >= 0 && index < theCount)
|
||||
{
|
||||
case NSRightMouseUp:
|
||||
case NSLeftMouseUp:
|
||||
/* right mouse up or left mouse up means we're done */
|
||||
done = YES;
|
||||
break;
|
||||
case NSRightMouseDragged:
|
||||
case NSLeftMouseDragged:
|
||||
lastLocation = [[self window] mouseLocationOutsideOfEventStream];
|
||||
[self setHighlightedItemIndex: index];
|
||||
lastIndex = index;
|
||||
}
|
||||
|
||||
while (!done)
|
||||
{
|
||||
event = [theApp nextEventMatchingMask: eventMask
|
||||
untilDate: theDistantFuture
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
#ifdef 0
|
||||
NSLog (@"location = (%f, %f, %f)", lastLocation.x, [[self window]
|
||||
frame].origin.x, [[self window] frame].size.width);
|
||||
switch ([event type])
|
||||
{
|
||||
case NSRightMouseUp:
|
||||
case NSLeftMouseUp:
|
||||
/* right mouse up or left mouse up means we're done */
|
||||
done = YES;
|
||||
break;
|
||||
case NSRightMouseDragged:
|
||||
case NSLeftMouseDragged:
|
||||
lastLocation = [[self window] mouseLocationOutsideOfEventStream];
|
||||
|
||||
#if 0
|
||||
NSLog (@"location = (%f, %f, %f)", lastLocation.x, [[self window]
|
||||
frame].origin.x, [[self window] frame].size.width);
|
||||
#endif
|
||||
|
||||
if (lastLocation.x > 0
|
||||
&& lastLocation.x < [[self window] frame].size.width) {
|
||||
lastLocation = [self convertPoint: lastLocation fromView:nil];
|
||||
if (lastLocation.x > 0
|
||||
&& lastLocation.x < [[self window] frame].size.width)
|
||||
{
|
||||
lastLocation = [self convertPoint: lastLocation
|
||||
fromView: nil];
|
||||
|
||||
index = (height - lastLocation.y) / cellSize.height;
|
||||
#ifdef 0
|
||||
NSLog (@"location = (%f, %f)", lastLocation.x, lastLocation.y);
|
||||
NSLog (@"index = %d\n", index);
|
||||
index = (height - lastLocation.y) / cellSize.height;
|
||||
#if 0
|
||||
NSLog (@"location = (%f, %f)",
|
||||
lastLocation.x, lastLocation.y);
|
||||
NSLog (@"index = %d\n", index);
|
||||
#endif
|
||||
if (index >= 0 && index < theCount) {
|
||||
if (index != lastIndex) {
|
||||
[self setHighlightedItemIndex:index];
|
||||
lastIndex = index;
|
||||
} else {
|
||||
if (weWereOut) {
|
||||
[self setHighlightedItemIndex:index];
|
||||
lastIndex = index;
|
||||
weWereOut = NO;
|
||||
}
|
||||
if (index >= 0 && index < theCount)
|
||||
{
|
||||
if (index != lastIndex)
|
||||
{
|
||||
[self setHighlightedItemIndex: index];
|
||||
lastIndex = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (weWereOut)
|
||||
{
|
||||
[self setHighlightedItemIndex: index];
|
||||
lastIndex = index;
|
||||
weWereOut = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (lastLocation.x > [[self window] frame].size.width)
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex: lastIndex];
|
||||
if (lastLocation.y > aRect.origin.y
|
||||
&& lastLocation.y < aRect.origin.y + aRect.size.height
|
||||
&& [[[menuv_menu itemArray] objectAtIndex: lastIndex]
|
||||
hasSubmenu])
|
||||
{
|
||||
weLeftMenu = YES;
|
||||
done = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setHighlightedItemIndex: -1];
|
||||
lastIndex = index;
|
||||
weWereOut = YES;
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
else if (lastLocation.x < 0)
|
||||
{
|
||||
if ([menuv_menu supermenu])
|
||||
{
|
||||
weRightMenu = YES;
|
||||
done = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setHighlightedItemIndex: -1];
|
||||
lastIndex = index;
|
||||
weWereOut = YES;
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME, Michael. This might be needed... or not?
|
||||
NSLog(@"This is the final else... its evil\n");
|
||||
if (lastIndex >= 0 && lastIndex < theCount)
|
||||
{
|
||||
[self setHighlightedItemIndex: -1];
|
||||
lastIndex = index;
|
||||
weWereOut = YES;
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
[window flushWindow];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!weLeftMenu && !weRightMenu && !weWereOut
|
||||
&& menuv_highlightedItemIndex != -1)
|
||||
{
|
||||
if (![[[menuv_menu itemArray] objectAtIndex: menuv_highlightedItemIndex]
|
||||
hasSubmenu])
|
||||
{
|
||||
BOOL finished = NO;
|
||||
NSMenu *aMenu = menuv_menu;
|
||||
|
||||
if (index >= 0 && index < theCount)
|
||||
selectedCell = [[menuv_menu itemArray] objectAtIndex: index];
|
||||
else
|
||||
selectedCell = nil;
|
||||
|
||||
[self setHighlightedItemIndex: -1];
|
||||
|
||||
if ([selectedCell action])
|
||||
[menuv_menu performActionForItem:
|
||||
[[menuv_menu itemArray] objectAtIndex: lastIndex]];
|
||||
|
||||
if ([selectedCell hasSubmenu])
|
||||
[[selectedCell target] close];
|
||||
|
||||
while (!finished)
|
||||
{ // "forward"cursive menu find.
|
||||
if ([aMenu attachedMenu])
|
||||
{
|
||||
aMenu = [aMenu attachedMenu];
|
||||
}
|
||||
else
|
||||
finished = YES;
|
||||
}
|
||||
}
|
||||
} else if (lastLocation.x > [[self window] frame].size.width) {
|
||||
NSRect aRect = [self rectOfItemAtIndex:lastIndex];
|
||||
if (lastLocation.y > aRect.origin.y && lastLocation.y <
|
||||
aRect.origin.y + aRect.size.height && [[[menuv_menu itemArray] objectAtIndex:lastIndex] hasSubmenu]) {
|
||||
weLeftMenu = YES;
|
||||
done = YES;
|
||||
} else {
|
||||
[self setHighlightedItemIndex:-1];
|
||||
lastIndex = index;
|
||||
weWereOut = YES;
|
||||
[window flushWindow];
|
||||
}
|
||||
} else if (lastLocation.x < 0) {
|
||||
if ([menuv_menu supermenu]) {
|
||||
weRightMenu = YES;
|
||||
done = YES;
|
||||
} else {
|
||||
[self setHighlightedItemIndex:-1];
|
||||
lastIndex = index;
|
||||
weWereOut = YES;
|
||||
[window flushWindow];
|
||||
}
|
||||
} else {
|
||||
// FIXME, Michael. This might be needed... or not?
|
||||
NSLog(@"This is the final else... its evil\n");
|
||||
if (lastIndex >= 0 && lastIndex < theCount) {
|
||||
[self setHighlightedItemIndex:-1];
|
||||
lastIndex = index;
|
||||
weWereOut = YES;
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
[window flushWindow];
|
||||
default:
|
||||
break;
|
||||
|
||||
finished = NO;
|
||||
|
||||
while (!finished)
|
||||
{ // Recursive menu close & deselect.
|
||||
if ([aMenu supermenu] && ![aMenu isTornOff])
|
||||
{
|
||||
[[[aMenu supermenu] menuView] setHighlightedItemIndex: -1];
|
||||
[aMenu close];
|
||||
aMenu = [aMenu supermenu];
|
||||
}
|
||||
else
|
||||
finished = YES;
|
||||
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (weRightMenu)
|
||||
{
|
||||
NSPoint cP = [[self window] convertBaseToScreen: lastLocation];
|
||||
|
||||
if (!weLeftMenu && !weRightMenu && !weWereOut && menuv_highlightedItemIndex != -1) {
|
||||
if (![[[menuv_menu itemArray] objectAtIndex:menuv_highlightedItemIndex] hasSubmenu]) {
|
||||
BOOL finished = NO;
|
||||
NSMenu *aMenu = menuv_menu;
|
||||
selectedCell = [[menuv_menu itemArray] objectAtIndex:index];
|
||||
[self setHighlightedItemIndex: -1];
|
||||
|
||||
[self setHighlightedItemIndex:-1];
|
||||
if ([menuv_menu supermenu] && ![menuv_menu isTornOff])
|
||||
{
|
||||
[self mouseUp:
|
||||
[NSEvent mouseEventWithType: NSLeftMouseUp
|
||||
location: cP
|
||||
modifierFlags: [event modifierFlags]
|
||||
timestamp: [event timestamp]
|
||||
windowNumber: [[self window] windowNumber]
|
||||
context: [event context]
|
||||
eventNumber: [event eventNumber]
|
||||
clickCount: [event clickCount]
|
||||
pressure: [event pressure]]];
|
||||
|
||||
if ([selectedCell action])
|
||||
[menuv_menu performActionForItem:[[menuv_menu itemArray] objectAtIndex:lastIndex]];
|
||||
[[[menuv_menu supermenu] menuView] mouseDown:
|
||||
[NSEvent mouseEventWithType: NSLeftMouseDragged
|
||||
location: cP
|
||||
modifierFlags: [event modifierFlags]
|
||||
timestamp: [event timestamp]
|
||||
windowNumber: [[[[menuv_menu supermenu] menuView] window] windowNumber]
|
||||
context: [event context]
|
||||
eventNumber: [event eventNumber]
|
||||
clickCount: [event clickCount]
|
||||
pressure: [event pressure]]];
|
||||
}
|
||||
}
|
||||
else if (weLeftMenu)
|
||||
{ /* The weLeftMenu case */
|
||||
NSPoint cP = [[self window] convertBaseToScreen: lastLocation];
|
||||
|
||||
NSLog(@"Urph.\n");
|
||||
|
||||
selectedCell = [[menuv_menu itemArray] objectAtIndex: lastIndex];
|
||||
if ([selectedCell hasSubmenu])
|
||||
[[selectedCell target] close];
|
||||
{
|
||||
[self mouseUp:
|
||||
[NSEvent mouseEventWithType: NSLeftMouseUp
|
||||
location: cP
|
||||
modifierFlags: [event modifierFlags]
|
||||
timestamp: [event timestamp]
|
||||
windowNumber: [[self window] windowNumber]
|
||||
context: [event context]
|
||||
eventNumber: [event eventNumber]
|
||||
clickCount: [event clickCount]
|
||||
pressure: [event pressure]]];
|
||||
|
||||
while (!finished) { // "forward"cursive menu find.
|
||||
if ([aMenu attachedMenu]) {
|
||||
aMenu = [aMenu attachedMenu];
|
||||
}
|
||||
else
|
||||
finished = YES;
|
||||
}
|
||||
|
||||
finished = NO;
|
||||
|
||||
while (!finished) { // Recursive menu close & deselect.
|
||||
if ([aMenu supermenu] && ![aMenu isTornOff]) {
|
||||
[[[aMenu supermenu] menuView] setHighlightedItemIndex:-1];
|
||||
[aMenu close];
|
||||
aMenu = [aMenu supermenu];
|
||||
}
|
||||
else
|
||||
finished = YES;
|
||||
|
||||
[window flushWindow];
|
||||
}
|
||||
[[[selectedCell target] menuView] mouseDown:
|
||||
[NSEvent mouseEventWithType: NSLeftMouseDragged
|
||||
location: cP
|
||||
modifierFlags: [event modifierFlags]
|
||||
timestamp: [event timestamp]
|
||||
windowNumber: [[[[selectedCell target] menuView] window] windowNumber]
|
||||
context: [event context]
|
||||
eventNumber: [event eventNumber]
|
||||
clickCount: [event clickCount]
|
||||
pressure: [event pressure]]];
|
||||
}
|
||||
}
|
||||
} else if (weRightMenu) {
|
||||
NSPoint cP = [[self window] convertBaseToScreen:lastLocation];
|
||||
|
||||
[self setHighlightedItemIndex:-1];
|
||||
|
||||
if ([menuv_menu supermenu] && ![menuv_menu isTornOff]) {
|
||||
[self mouseUp:
|
||||
[NSEvent mouseEventWithType:NSLeftMouseUp
|
||||
location:cP
|
||||
modifierFlags:[event modifierFlags]
|
||||
timestamp:[event timestamp]
|
||||
windowNumber:[[self window] windowNumber]
|
||||
context:[event context]
|
||||
eventNumber:[event eventNumber]
|
||||
clickCount:[event clickCount]
|
||||
pressure:[event pressure]]];
|
||||
|
||||
[[[menuv_menu supermenu] menuView] mouseDown:
|
||||
[NSEvent mouseEventWithType:NSLeftMouseDragged
|
||||
location:cP
|
||||
modifierFlags:[event modifierFlags]
|
||||
timestamp:[event timestamp]
|
||||
windowNumber:[[[[menuv_menu supermenu] menuView] window] windowNumber]
|
||||
context:[event context]
|
||||
eventNumber:[event eventNumber]
|
||||
clickCount:[event clickCount]
|
||||
pressure:[event pressure]]];
|
||||
}
|
||||
} else if (weLeftMenu) { /* The weLeftMenu case */
|
||||
NSPoint cP = [[self window] convertBaseToScreen:lastLocation];
|
||||
|
||||
NSLog(@"Urph.\n");
|
||||
|
||||
selectedCell = [[menuv_menu itemArray] objectAtIndex:lastIndex];
|
||||
if ([selectedCell hasSubmenu]) {
|
||||
[self mouseUp:
|
||||
[NSEvent mouseEventWithType:NSLeftMouseUp
|
||||
location:cP
|
||||
modifierFlags:[event modifierFlags]
|
||||
timestamp:[event timestamp]
|
||||
windowNumber:[[self window] windowNumber]
|
||||
context:[event context]
|
||||
eventNumber:[event eventNumber]
|
||||
clickCount:[event clickCount]
|
||||
pressure:[event pressure]]];
|
||||
|
||||
[[[selectedCell target] menuView] mouseDown:
|
||||
[NSEvent mouseEventWithType:NSLeftMouseDragged
|
||||
location:cP
|
||||
modifierFlags:[event modifierFlags]
|
||||
timestamp:[event timestamp]
|
||||
windowNumber:[[[[selectedCell target] menuView] window] windowNumber]
|
||||
context:[event context]
|
||||
eventNumber:[event eventNumber]
|
||||
clickCount:[event clickCount]
|
||||
pressure:[event pressure]]];
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
- (void)mouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
[self trackWithEvent:theEvent];
|
||||
[self trackWithEvent: theEvent];
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue