Remove explicit passing of window to shortcuts
This commit is contained in:
parent
04c77831b5
commit
edb6a81812
@ -45,8 +45,11 @@ extension Button {
|
|||||||
/// - window: The application window.
|
/// - window: The application window.
|
||||||
/// - active: Whether the keyboard shortcut is active.
|
/// - active: Whether the keyboard shortcut is active.
|
||||||
/// - Returns: The button.
|
/// - Returns: The button.
|
||||||
public func keyboardShortcut(_ shortcut: String, window: AdwaitaWindow, active: Bool = true) -> AnyView {
|
public func keyboardShortcut(_ shortcut: String, active: Bool = true) -> AnyView {
|
||||||
onUpdate {
|
inspect { _, data, _ in
|
||||||
|
guard let window = data.sceneStorage.pointer as? AdwaitaWindow else {
|
||||||
|
return
|
||||||
|
}
|
||||||
if active {
|
if active {
|
||||||
window.app.addKeyboardShortcut(shortcut, id: shortcut, window: window) { self.clicked?() }
|
window.app.addKeyboardShortcut(shortcut, id: shortcut, window: window) { self.clicked?() }
|
||||||
} else {
|
} else {
|
||||||
@ -63,12 +66,15 @@ extension Button {
|
|||||||
/// - window: The application.
|
/// - window: The application.
|
||||||
/// - active: Whether the keyboard shortcut is active.
|
/// - active: Whether the keyboard shortcut is active.
|
||||||
/// - Returns: The button.
|
/// - Returns: The button.
|
||||||
public func keyboardShortcut(_ shortcut: String, app: AdwaitaApp, active: Bool = true) -> AnyView {
|
public func appKeyboardShortcut(_ shortcut: String, active: Bool = true) -> AnyView {
|
||||||
onUpdate {
|
inspect { _, data, _ in
|
||||||
|
guard let window = data.sceneStorage.pointer as? AdwaitaWindow else {
|
||||||
|
return
|
||||||
|
}
|
||||||
if active {
|
if active {
|
||||||
app.addKeyboardShortcut(shortcut, id: shortcut) { self.clicked?() }
|
window.app.addKeyboardShortcut(shortcut, id: shortcut) { self.clicked?() }
|
||||||
} else {
|
} else {
|
||||||
app.removeKeyboardShortcut(id: shortcut)
|
window.app.removeKeyboardShortcut(id: shortcut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user