Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FloatingPanel: NSPanel {
- init() {
- super.init(contentRect: getContentRect(),
- styleMask: [.fullSizeContentView],
- backing: .buffered,
- defer: false)
- /// Allow the panel to be on top of other windows
- isFloatingPanel = true
- level = .floating
- /// Allow the pannel to be overlaid in a fullscreen space
- collectionBehavior.insert(.fullScreenAuxiliary)
- collectionBehavior.insert(.canJoinAllSpaces)
- /// Don't show a window title, even if it's set
- titleVisibility = .hidden
- titlebarAppearsTransparent = true
- /// Since there is no title bar make the window moveable by dragging on the background
- isMovableByWindowBackground = false
- /// Hide when unfocused
- hidesOnDeactivate = false
- /// Hide all traffic light buttons
- standardWindowButton(.closeButton)?.isHidden = true
- standardWindowButton(.miniaturizeButton)?.isHidden = true
- standardWindowButton(.zoomButton)?.isHidden = true
- backgroundColor = .clear
- /// Sets animations accordingly
- animationBehavior = .utilityWindow
- }
- /// `canBecomeKey` and `canBecomeMain` are both required so that text inputs inside the panel can receive focus
- override var canBecomeKey: Bool {
- return true
- }
- override var canBecomeMain: Bool {
- return true
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement