mouse button callbacks returns bool for consumption

This commit is contained in:
Mitchell Hashimoto
2024-06-30 09:40:06 -07:00
parent 38c31e98f1
commit 03f37087a5
5 changed files with 52 additions and 18 deletions

View File

@@ -471,15 +471,39 @@ extension Ghostty {
override func rightMouseDown(with event: NSEvent) {
guard let surface = self.surface else { return }
guard let surface = self.surface else { return super.rightMouseDown(with: event) }
let mods = Ghostty.ghosttyMods(event.modifierFlags)
ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_PRESS, GHOSTTY_MOUSE_RIGHT, mods)
if (ghostty_surface_mouse_button(
surface,
GHOSTTY_MOUSE_PRESS,
GHOSTTY_MOUSE_RIGHT,
mods
)) {
// Consumed
return
}
// Mouse event not consumed
super.rightMouseDown(with: event)
}
override func rightMouseUp(with event: NSEvent) {
guard let surface = self.surface else { return }
guard let surface = self.surface else { return super.rightMouseUp(with: event) }
let mods = Ghostty.ghosttyMods(event.modifierFlags)
ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_RELEASE, GHOSTTY_MOUSE_RIGHT, mods)
if (ghostty_surface_mouse_button(
surface,
GHOSTTY_MOUSE_RELEASE,
GHOSTTY_MOUSE_RIGHT,
mods
)) {
// Handled
return
}
// Mouse event not consumed
super.rightMouseUp(with: event)
}
override func mouseMoved(with event: NSEvent) {
@@ -842,6 +866,11 @@ extension Ghostty {
ghostty_surface_key(surface, key_ev)
}
}
override func menu(for event: NSEvent) -> NSMenu? {
Ghostty.logger.warning("menu: event!")
return nil
}
// MARK: Menu Handlers