I have a Paste and Match Style menuItem that is enabled whoever a TextEdit-based control has the focus. This doesn’t work when the focus is a NSSearchFieldControlMBS (window.focus returns nil), and there is no enableMenuItems event in NSSearchFieldControlMBS. What’s the best way to know that the cursor is in the NSSearchFieldControlMBS control? I have multiple NSSearchFieldControlMBS controls and I could set a boolean for for each, but I’m hoping there’s a more general solution.
A corollary problem – if I do enable the Paste and Match Style, when the menuHandler fires how would I get the clipboard text into the search field when not knowing it had the focus? I suppose I could also put the name of the MBS control in a property when it got the focus and replace any text in that field with the clipboard text. But that’s suboptimal because the paste should insert at the cursor, not replace the text. This is too rickety a construct.