NSOutlineView Bug (continued)
NSOutlineView Bug (continued)
- Subject: NSOutlineView Bug (continued)
- From: Steve Gehrman <email@hidden>
- Date: Thu, 6 Sep 2001 17:01:18 -0700
I'm trying to get around the NSOutlineView bug dealing with option
clicking the disclosure triangle. But for some strange reason, my hack
has no effect.
I subclassed my outlineView and overrode mousedown to detect when the
alternate key is down and if so, create a new event without the option
key down and send it along. I also tried posting the event and that
didn't work either.
Steve Gehrman
- (void)mouseDown:(NSEvent *)event
{
if ([event modifierFlags] & NSAlternateKeyMask)
[self optionKeyHack:event];
else
{
...
}
}
- (void)optionKeyHack:(NSEvent *)event
{
NSPoint point;
int rowIndex;
id item;
point = [self convertPoint:[event locationInWindow] fromView:nil];
rowIndex = [self rowAtPoint:point];
if (rowIndex != -1)
{
item = [self itemAtRow:rowIndex];
// we don't care about option collapsing
if ([self isItemExpanded:item] || [_dataSource outlineView:self
shouldExpandAllForItem:item])
[super mouseDown:event];
else
{
NSEvent *newEvent;
unsigned int newModifiers = [event modifierFlags];
// clear the alternate key
newModifiers = (newModifiers & ~NSAlternateKeyMask);
newEvent = [NSEvent mouseEventWithType:[event type]
location:[event locationInWindow]
modifierFlags:newModifiers
timestamp:[event timestamp]
windowNumber:[event windowNumber]
context:[event context]
eventNumber:[event eventNumber]
clickCount:[event clickCount]
pressure:[event pressure]];
// ** both of these have no effect, the outline view still thinks the
option key is down?
[NSApp postEvent:newEvent atStart:YES];
// [super mouseDown:newEvent];
}
}
else
[super mouseDown:event];
}