Re: Pop Up Menu in NSTableView
Re: Pop Up Menu in NSTableView
- Subject: Re: Pop Up Menu in NSTableView
- From: Pax <email@hidden>
- Date: Sun, 24 Mar 2013 22:16:09 +0000
Ah. I shall have to look that up. Do you know of any good examples for view based tables?
As to the backtrace:
* thread #1: tid = 0x2403, 0x00000001004cb55e DefaultPlugin`-[DefaultPlug cellPreferenceChanged:](self=0x000000010182a5b0, _cmd=0x0000000101826ea0, sender=0x000000010182cc00) + 30 at DefaultPlugin.m:233, stop reason = breakpoint 1.1
frame #0: 0x00000001004cb55e DefaultPlugin`-[DefaultPlug cellPreferenceChanged:](self=0x000000010182a5b0, _cmd=0x0000000101826ea0, sender=0x000000010182cc00) + 30 at DefaultPlugin.m:233
frame #1: 0x00007fff81d45989 AppKit`-[NSApplication sendAction:to:from:] + 342
frame #2: 0x00007fff81d457e7 AppKit`-[NSControl sendAction:to:] + 85
frame #3: 0x00007fff81d4571b AppKit`-[NSCell _sendActionFrom:] + 138
frame #4: 0x00007fff81d45989 AppKit`-[NSApplication sendAction:to:from:] + 342
frame #5: 0x00007fff81e7b37c AppKit`-[NSMenuItem _corePerformAction] + 406
frame #6: 0x00007fff81e7b06a AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 133
frame #7: 0x00007fff81b6828f AppKit`-[NSMenu _internalPerformActionForItemAtIndex:] + 36
frame #8: 0x00007fff81b68117 AppKit`-[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 135
frame #9: 0x00007fff81e74175 AppKit`NSSLMMenuEventHandler + 342
frame #10: 0x00007fff8ae81d1a HIToolbox`DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1206
frame #11: 0x00007fff8ae811e9 HIToolbox`SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 410
frame #12: 0x00007fff8ae96fc9 HIToolbox`SendEventToEventTarget + 40
frame #13: 0x00007fff8aecdca9 HIToolbox`SendHICommandEvent(unsigned int, HICommand const*, unsigned int, unsigned int, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 443
frame #14: 0x00007fff8ae72a21 HIToolbox`SendMenuCommandWithContextAndModifiers + 59
frame #15: 0x00007fff8ae729d3 HIToolbox`SendMenuItemSelectedEvent + 254
frame #16: 0x00007fff8ae7285f HIToolbox`FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*) + 94
frame #17: 0x00007fff8afe8e79 HIToolbox`PopUpMenuSelectCore(MenuData*, Point, double, Point, unsigned short, unsigned int, Rect const*, unsigned short, unsigned int, Rect const*, Rect const*, __CFString const*, OpaqueMenuRef**, unsigned short*) + 1673
frame #18: 0x00007fff8afe8794 HIToolbox`_HandlePopUpMenuSelection7 + 629
frame #19: 0x00007fff81ef754b AppKit`_NSSLMPopUpCarbonMenu3 + 3916
frame #20: 0x00007fff82258caa AppKit`_NSPopUpCarbonMenu3 + 39
frame #21: 0x00007fff81ef650c AppKit`-[NSCarbonMenuImpl popUpMenu:atLocation:width:forView:withSelectedItem:withFont:withFlags:withOptions:] + 346
frame #22: 0x00007fff820ba295 AppKit`-[NSPopUpButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 540
frame #23: 0x00007fff8214aeb0 AppKit`-[NSTableView _tryCellBasedMouseDown:atRow:column:withView:] + 1650
frame #24: 0x00007fff8214c32b AppKit`-[NSTableView mouseDown:] + 4540
frame #25: 0x00007fff81d3a53e AppKit`-[NSWindow sendEvent:] + 6853
frame #26: 0x00007fff81d36674 AppKit`-[NSApplication sendEvent:] + 5761
frame #27: 0x00007fff81c4c24a AppKit`-[NSApplication run] + 636
frame #28: 0x00007fff81bf0c06 AppKit`NSApplicationMain + 869
frame #29: 0x00000001000035b2 TestApp`main(argc=3, argv=0x00007fff5fbff858) + 34 at main.m:13
frame #30: 0x0000000100001c94 TestApp`start + 52
On 24 Mar 2013, at 22:06, Quincey Morris <email@hidden> wrote:
> On Mar 24, 2013, at 14:50 , Pax <email@hidden> wrote:
>
> You may be more successful if you use a view-based table rather than a cell-based table. One of the reasons we have view-based tables is to be able to avoid dealing with cells directly, in situations like this.
>
> However, if you've never used a view-based table before, the learning curve is fairly steep (though short).
>
>> As to your second question, I've connected the "selector" connection from the cell to 'cellPreferenceChanged'. In my header I have:
>> IBOutlet NSPopUpButtonCell* preferenceCell;
>> - (IBAction)cellPreferenceChanged:(id)sender;
>> and both are hooked up in IB.
>
> Ugh, it doesn't look right to set up an outlet to a cell like this. Table views deal with cells at two points:
>
> 1. When obtaining a cell for a given column. It uses the delegate method 'tableView:dataCellForTableColumn:row:' to get the cell, which may or may not be the one that's in the nib file. It does a certain amount of configuration of the cell after this method returns.
>
> 2. When preparing the cell for a drawing specific row. It uses the delegate method 'tableView:willDisplayCell:forTableColumn:row:', and does more configuration before this method is called.
>
> So, rather than keeping an outlet to a cell that might not be the one used in any given case, you should use one of the above delegate methods to find out which cell is actually being used.
>
> That's if you need to know the cell in your code, which is doubtful.
>
>> As to the third, how do I find out?
>
> In Xcode, set a breakpoint in the action method. When you get to the breakpoint, go to the debugger console and type the "bt" command. That will give a backtrace you can copy and paste into an email.
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden