I'm a beginner in OSX development so I hope my question will find a solution here.
I have an NSTokenField
in my app and I implemented the tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:
method.
Everything works fine but the present result look like this :
What I would like is to make it look like this: (similar to the completion in the Mail app)
Which means that I would like the completion list to take all the NSTokenField width. Using the Accessibility Inspector, I can see that the hierarchy corresponding to the first sreenshot is:
AXScrollArea -> AXList -> AXTextField
while the one corresponding to the second screenshot is:
AXScrollArea -> AXTable -> AXRow:AXTableRow -> AXTextField
So I suppose I have to use an NSTableView
to display the completion list, but I don't know how to achieve this. Does anybody know how is that possible?
Thanks in advance for your help.
EDIT
At least 2 people suggested that I implement the tokenField:menuForRepresentedObject:
method and define the menu width with the appropriate NSMenu
property. But this method is used to define a menu for a given token and I already implemented it:
def tokenField(tokenField, menuForRepresentedObject:representedObject)
theMenu = NSMenu.alloc.initWithTitle("Email address context menu")
item_0 = theMenu.insertItemWithTitle('add_to_address_book'.localized, action:'add_to_address_book', keyEquivalent:"", atIndex:0)
item_0.setTarget(self)
item_1 = theMenu.insertItemWithTitle('new_message'.localized, action:'new_message', keyEquivalent:"", atIndex:1)
item_1.setTarget(self)
theMenu
end
Which gives me something like this:
Something great but not what I am asking here.