Popover keys now use virtual codes.
This commit is contained in:
@@ -8,7 +8,7 @@ class PopoverPanel: NSPanel {
|
|||||||
)
|
)
|
||||||
|
|
||||||
override var canBecomeKey: Bool { true }
|
override var canBecomeKey: Bool { true }
|
||||||
|
|
||||||
init(viewController: NSViewController) {
|
init(viewController: NSViewController) {
|
||||||
super.init(
|
super.init(
|
||||||
contentRect: CGRect(x: 0, y: 0, width: 100, height: 100),
|
contentRect: CGRect(x: 0, y: 0, width: 100, height: 100),
|
||||||
@@ -18,7 +18,7 @@ class PopoverPanel: NSPanel {
|
|||||||
defer: false
|
defer: false
|
||||||
)
|
)
|
||||||
super.contentViewController = viewController
|
super.contentViewController = viewController
|
||||||
|
|
||||||
title = ""
|
title = ""
|
||||||
isMovable = true
|
isMovable = true
|
||||||
isMovableByWindowBackground = true
|
isMovableByWindowBackground = true
|
||||||
@@ -27,13 +27,13 @@ class PopoverPanel: NSPanel {
|
|||||||
level = .statusBar
|
level = .statusBar
|
||||||
titleVisibility = .hidden
|
titleVisibility = .hidden
|
||||||
titlebarAppearsTransparent = true
|
titlebarAppearsTransparent = true
|
||||||
|
|
||||||
animationBehavior = .none
|
animationBehavior = .none
|
||||||
collectionBehavior = [.moveToActiveSpace, .fullScreenAuxiliary,
|
collectionBehavior = [.moveToActiveSpace, .fullScreenAuxiliary,
|
||||||
.transient]
|
.transient]
|
||||||
isReleasedWhenClosed = false
|
isReleasedWhenClosed = false
|
||||||
hidesOnDeactivate = false
|
hidesOnDeactivate = false
|
||||||
|
|
||||||
standardWindowButton(.closeButton)?.isHidden = true
|
standardWindowButton(.closeButton)?.isHidden = true
|
||||||
standardWindowButton(.miniaturizeButton)?.isHidden = true
|
standardWindowButton(.miniaturizeButton)?.isHidden = true
|
||||||
standardWindowButton(.zoomButton)?.isHidden = true
|
standardWindowButton(.zoomButton)?.isHidden = true
|
||||||
@@ -43,24 +43,20 @@ class PopoverPanel: NSPanel {
|
|||||||
Self.logger.debug("performKeyEquivalent keyCode=\(event.keyCode)")
|
Self.logger.debug("performKeyEquivalent keyCode=\(event.keyCode)")
|
||||||
let commandKey = NSEvent.ModifierFlags.command.rawValue
|
let commandKey = NSEvent.ModifierFlags.command.rawValue
|
||||||
|
|
||||||
// TODO: Make these depend on virtual keycodes, instead of
|
|
||||||
// characters.
|
|
||||||
if event.type == NSEvent.EventType.keyDown {
|
if event.type == NSEvent.EventType.keyDown {
|
||||||
if (event.modifierFlags.rawValue &
|
if (event.modifierFlags.rawValue &
|
||||||
NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue)
|
NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue)
|
||||||
== commandKey,
|
== commandKey, event.keyCode == 13 // W
|
||||||
event.charactersIgnoringModifiers! == "w"
|
|
||||||
{
|
{
|
||||||
resignKey()
|
resignKey()
|
||||||
return true
|
return true
|
||||||
} else if (event.modifierFlags.rawValue &
|
} else if (event.modifierFlags.rawValue &
|
||||||
NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue)
|
NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue)
|
||||||
== commandKey,
|
== commandKey, event.keyCode == 12 // Q
|
||||||
event.charactersIgnoringModifiers! == "q"
|
|
||||||
{
|
{
|
||||||
NSApplication.shared.terminate(self)
|
NSApplication.shared.terminate(self)
|
||||||
return true
|
return true
|
||||||
} else if event.keyCode == 53 {
|
} else if event.keyCode == 53 { // ESC
|
||||||
resignKey()
|
resignKey()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user