4

I want to present emoji panel and using NSApp.orderFrontCharacterPalette(nil). it works fine, but sometimes it appears at random place and i want it to be "constrained" to text field where I'm going to use it. Can i set frame of panel manually or do it in another way? thanks for help

  • Maybe you can set the frame in the preferences. Take a look at com.apple.CharacterPaletteIM.plist, `CVPerProcessWindowState`. – Willeke Dec 02 '16 at 14:59

1 Answers1

1

It requires your text field to be the first responder.

You could make a text field the first responder by calling following method:

Swift:

textField.window?.makeFirstResponder(textField)

Objective-C:

[[textField window] makeFirstResponder:textField];

Hope it helps.

Mehdzor
  • 789
  • 4
  • 9
  • 23
  • Apple says about `becomeFirstResponder`: "Use the `NSWindow` `makeFirstResponder:` method, not this method, to make an object the first responder. Never invoke this method directly.". – Willeke Dec 02 '16 at 14:07
  • Thanks for an advice, I would change my answer. – Mehdzor Dec 02 '16 at 14:16
  • I've done this and the character palette still shows up as a floating window. I've written a related question here in case you can help: https://stackoverflow.com/questions/54138430/emoji-list-in-nspopover-on-macos-like-messages-app – Clifton Labrum Jan 11 '19 at 04:00