Skip to content

Instantly share code, notes, and snippets.

@KevinGutowski
Created June 12, 2019 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KevinGutowski/37ac08d9512ab3d324294a6bd6ccd84e to your computer and use it in GitHub Desktop.
Save KevinGutowski/37ac08d9512ab3d324294a6bd6ccd84e to your computer and use it in GitHub Desktop.
Trying to get NSPanel to expand downward.
let threadDictionary = NSThread.mainThread().threadDictionary()
let panelID = "com.betterTypePanel.panel"
if (threadDictionary[panelID]) {
let panel = threadDictionary[panelID]
panel.close()
threadDictionary.removeObjectForKey(panelID)
}
var panelWidth = 312
var panelHeight = 210
let panel = NSPanel.alloc().init()
panel.setFrame_display(NSMakeRect(0, 0, panelWidth, panelHeight), true)
panel.setStyleMask(NSTexturedBackgroundWindowMask | NSTitledWindowMask | NSClosableWindowMask)
panel.title = "Testing"
panel.center()
panel.makeKeyAndOrderFront(null)
panel.setLevel(NSFloatingWindowLevel)
panel.standardWindowButton(NSWindowMiniaturizeButton).setHidden(true)
panel.standardWindowButton(NSWindowZoomButton).setHidden(true)
threadDictionary[panelID] = panel
let x1 = panel.frame().origin.x
let y1 = panel.frame().origin.y
panel.setFrame_display_animate(NSMakeRect(x1, y1, panelWidth, panelHeight + 50), true, true)
// Fix to get panel to animate downward
//panel.setFrame_display_animate(NSMakeRect(x1, y1 - 50, panelWidth, panelHeight + 50), true, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment