While using NSTokenField
something strange is happening, as shown in the images below :
As I type A
, selection from popup is shown.
I scrolled it
Some more scroll, and it went below the visible area.
This is a behaviour with all the tableviews. The view behind the rows are visible , but it automatically springs to normal position. But not in this case.
It is fine in Mail app, it is working fine.
My implementation is :
Created an NSTokenField
.
Set its delegate to AppDelegate.
In the implementation file
-(NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex{
return @[@"A",@"B",@"C"];
}
Even the sample code from apple documentation behaves incorrectly.
How can I make it auto-spring or restrict by some code?
What you see in Mail.app is not an actual NSMenu (Apple cheats, shocking!). Turns out, it's actually a custom NSTextField linked to an NSTableView stuck in a transparent window.
It's a fairly old trick to get around the extremely poor version of scrollWheel:
NSMenu happens to have implemented. MTTokenField is a mature alternative to pulling your hair out trying to stick a scroll view in an NSMenu.