From e1320be757a14ceb9e7da4e0e269b8eedc61ff5f Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Thu, 21 Dec 2023 23:47:45 -0800 Subject: [PATCH] macos: handle middle click This adds middle-click support to MacOS. Very simple update, since everything else is in place to handle mouse clicks in the embedded runtime already, we just needed to add the event handlers in the UI. --- macos/Sources/Ghostty/SurfaceView.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index ae3bd599a..a75cbe255 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -635,6 +635,21 @@ extension Ghostty { ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_RELEASE, GHOSTTY_MOUSE_LEFT, mods) } + override func otherMouseDown(with event: NSEvent) { + guard let surface = self.surface else { return } + guard event.buttonNumber == 2 else { return } + let mods = Ghostty.ghosttyMods(event.modifierFlags) + ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_PRESS, GHOSTTY_MOUSE_MIDDLE, mods) + } + + override func otherMouseUp(with event: NSEvent) { + guard let surface = self.surface else { return } + guard event.buttonNumber == 2 else { return } + let mods = Ghostty.ghosttyMods(event.modifierFlags) + ghostty_surface_mouse_button(surface, GHOSTTY_MOUSE_RELEASE, GHOSTTY_MOUSE_MIDDLE, mods) + } + + override func rightMouseDown(with event: NSEvent) { guard let surface = self.surface else { return } let mods = Ghostty.ghosttyMods(event.modifierFlags)