I'm making a bridge for react-native-macos. I need NSPanel with the same behaviour as Spotlight. I programmatically created it, but have questions:
private var panel = NSPanel()
private var textField = NSTextField(frame: NSMakeRect(0,0,400,40))
var frame: NSRect = CGRect(x: 0, y: 0, width: 400, height: 40)
frame.size = NSSize(width: 400, height: 60)
panel.setFrame(frame, display: true)
let view: NSView = NSView(frame: frame)
myTextField.stringValue = "Some text"
myTextField.isEnabled = true
myTextField.font = NSFont.systemFont(ofSize: 28)
view.addSubview(myTextField)
panel.contentView?.addSubview(view)
panel.makeKeyAndOrderFront(panel)
panel.center()
This works for me
panel.level = .mainMenu