Does anyone know how to set the focus for a NSToolbarSearchfieldMBS? Adding the searchfield is no problem:
[code] SearchField = New NSToolbarSearchField(self.getWindowName)
SearchFieldItem = New NSToolbarItemMBS(kSearch)
SearchFieldItem.paletteLabel = kSearch
SearchFieldItem.view = SearchField
SearchFieldItem.
dim theToolbar as NSToolbarMBS = self.NSToolbarMBS
dim items() as NSToolbarItemMBS = theToolbar.items
for each currentItem as NSToolbarItemMBS in items
if currentItem.label = “Search” then
currentItem.label = kSearch
currentItem.view = SearchField
currentItem.maxSize = NSMakeSizeMBS(300, SearchFieldExtras.MainToolbarNSSearchFieldHeight)
currentItem.minSize = NSMakeSizeMBS(150, SearchFieldExtras.MainToolbarNSSearchFieldHeight)
end if
next[/code]
But how do I set the focus in code to this control?
// Set Focus on Searchfield
#If TargetCocoa
Call WindowMain.NSWindowMBS.makeFirstResponder(NSToolbarMain(WindowMain.OSXMainToolbar).SearchField)
#EndIf
[code] dim theToolbar as NSToolbarMBS = self.NSToolbarMBS
dim items() as NSToolbarItemMBS = theToolbar.items
for each currentItem as NSToolbarItemMBS in items
if currentItem.label = kSearch then
call self.NSWindowMBS.makeFirstResponder(currentItem.view)
end if
next[/code]
Since Yosemite I’m getting the focusring, but not a blinking cursor first. Only after I start typing, then I have a blinking cursor.
The same thing happens when I click to another window and then clicking back to the searchfield of the initial window: the window gets activated and the searchfield shows a focusring, but no blinker.
Only after a second click onto the field, then a blinking cursor appears.