Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
feat: allow mouse-button shortcuts for Paste Last Transcription
Tom3b2dfe787f88
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 5f4d235d..19878293 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -117,7 +117,12 @@ enum ShortcutRecordingTarget: Hashable {}var allowsMouseShortcut: Bool {- self.isPrimaryDictation+ switch self {+ case .primaryDictation, .pasteLast:+ return true+ case .secondaryDictation, .command, .edit, .cancel, .dictationPrompt, .newPrompt:+ return false+ }}var isPrimaryDictation: Bool {@@ -993,7 +998,7 @@ struct ContentView: View {private func shortcutConflictMessage(for shortcut: HotkeyShortcut, target: ShortcutRecordingTarget) -> String? {if shortcut.isMouseShortcut {guard target.allowsMouseShortcut else {- return "Mouse clicks can only be assigned to Primary Dictation Shortcut"+ return "Mouse clicks can only be assigned to Primary Dictation or Paste Last Transcription"}if shortcut.isUnmodifiedLeftOrRightClick, let mouseButton = shortcut.mouseButton {diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swiftindex 6a260411..c0272aa5 100644--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift@@ -902,18 +902,14 @@ final class GlobalHotkeyManager: NSObject {case .leftMouseDown, .rightMouseDown, .otherMouseDown:self.markOtherInputDuringModifierOnly()- let mouseButton = self.mouseButton(from: event)- if self.primaryShortcuts.contains(where: { $0.matchesMouse(button: mouseButton, modifiers: eventModifiers) }) {- guard self.beginPrimaryShortcutPress(.mouse(mouseButton)) else { return nil }- self.handlePrimaryDictationTriggerDown()+ if self.handleMouseShortcutDown(event, modifiers: eventModifiers) {return nil}case .leftMouseUp, .rightMouseUp, .otherMouseUp:- let mouseButton = self.mouseButton(from: event)- guard self.finishPrimaryShortcutPress(.mouse(mouseButton)) else { break }- self.handlePrimaryDictationTriggerUp()- return nil+ if self.handleMouseShortcutUp(event) {+ return nil+ }case .flagsChanged:if HotkeyShortcut.modifierFlag(forKeyCode: keyCode) != nil {@@ -1669,6 +1665,47 @@ final class GlobalHotkeyManager: NSObject {}}+ /// Handles a mouse-button down event against the configured mouse shortcuts. Returns true when+ /// the event was consumed. "Paste Last Transcription" is a one-shot trigger (mirrors the keyboard+ /// path); primary dictation begins a press here and ends it on mouse-up.+ private func handleMouseShortcutDown(_ event: CGEvent, modifiers eventModifiers: NSEvent.ModifierFlags) -> Bool {+ let mouseButton = self.mouseButton(from: event)++ if SettingsStore.shared.pasteLastTranscriptionShortcutEnabled,+ let pasteShortcut = SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut,+ pasteShortcut.matchesMouse(button: mouseButton, modifiers: eventModifiers)+ {+ self.triggerPasteLastTranscription(isAutorepeat: false)+ return true+ }++ if self.primaryShortcuts.contains(where: { $0.matchesMouse(button: mouseButton, modifiers: eventModifiers) }) {+ guard self.beginPrimaryShortcutPress(.mouse(mouseButton)) else { return true }+ self.handlePrimaryDictationTriggerDown()+ return true+ }++ return false+ }++ /// Handles a mouse-button up event. Swallows the up that pairs with a consumed paste mouse-down+ /// so the focused app never sees an orphaned mouse-up; otherwise ends a primary dictation press.+ private func handleMouseShortcutUp(_ event: CGEvent) -> Bool {+ let mouseButton = self.mouseButton(from: event)++ if SettingsStore.shared.pasteLastTranscriptionShortcutEnabled,+ let pasteShortcut = SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut,+ pasteShortcut.isMouseShortcut,+ pasteShortcut.mouseButton == mouseButton+ {+ return true+ }++ guard self.finishPrimaryShortcutPress(.mouse(mouseButton)) else { return false }+ self.handlePrimaryDictationTriggerUp()+ return true+ }+private func triggerPasteLastTranscription(isAutorepeat: Bool) {Task { @MainActor [weak self] inguard let self = self else { return }diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex a1cc7a4b..b7e0f8ee 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -143,6 +143,18 @@ final class HotkeyShortcutTests: XCTestCase {}}+ func testPasteLastTranscriptionShortcutSupportsMouseButton() throws {+ try self.withRestoredDefaults(keys: [self.pasteLastTranscriptionShortcutKey]) {+ let mouseShortcut = HotkeyShortcut(mouseButton: 3, modifierFlags: [.option])+ SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut = mouseShortcut++ let stored = SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut+ XCTAssertEqual(stored, mouseShortcut)+ XCTAssertTrue(stored?.isMouseShortcut ?? false)+ XCTAssertTrue(stored?.matchesMouse(button: 3, modifiers: [.option]) ?? false)+ }+ }+private func withRestoredDefaults(keys: [String], run: () throws -> Void) rethrows {let defaults = UserDefaults.standardvar snapshot: [String: Any] = [:]