Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2023
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. class FloatingPanel: NSPanel {
  2. init() {
  3. super.init(contentRect: getContentRect(),
  4. styleMask: [.fullSizeContentView],
  5. backing: .buffered,
  6. defer: false)
  7.  
  8. /// Allow the panel to be on top of other windows
  9. isFloatingPanel = true
  10. level = .floating
  11.  
  12. /// Allow the pannel to be overlaid in a fullscreen space
  13. collectionBehavior.insert(.fullScreenAuxiliary)
  14. collectionBehavior.insert(.canJoinAllSpaces)
  15.  
  16. /// Don't show a window title, even if it's set
  17. titleVisibility = .hidden
  18. titlebarAppearsTransparent = true
  19.  
  20. /// Since there is no title bar make the window moveable by dragging on the background
  21. isMovableByWindowBackground = false
  22.  
  23. /// Hide when unfocused
  24. hidesOnDeactivate = false
  25.  
  26. /// Hide all traffic light buttons
  27. standardWindowButton(.closeButton)?.isHidden = true
  28. standardWindowButton(.miniaturizeButton)?.isHidden = true
  29. standardWindowButton(.zoomButton)?.isHidden = true
  30.  
  31. backgroundColor = .clear
  32.  
  33. /// Sets animations accordingly
  34. animationBehavior = .utilityWindow
  35. }
  36.  
  37. /// `canBecomeKey` and `canBecomeMain` are both required so that text inputs inside the panel can receive focus
  38. override var canBecomeKey: Bool {
  39. return true
  40. }
  41.  
  42. override var canBecomeMain: Bool {
  43. return true
  44. }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement