Skip to content

Support mouse back/forward buttons for navigation #58

@lambdalisue

Description

@lambdalisue

Summary

macOS mouse side buttons (back/forward) do not trigger navigation in the app. Users expect these buttons to work like in web browsers and other native apps.

Current Behavior

  • ✅ Keyboard shortcuts work (Cmd+[ / Cmd+])
  • ✅ Header UI buttons work (◀ ▶)
  • ❌ Mouse side buttons (button 3/4) do nothing
  • ❌ Trackpad two-finger swipe gestures do not work

Technical Analysis

The current implementation only handles left-click (0) and middle-click (1) in the WebView:

// markdown.rs
if (event.button === 0 || event.button === 1) {
    event.preventDefault();
    window.handleMarkdownLinkClick('{escaped_href}', event.button);
}

Mouse back/forward buttons (button: 3 for back, button: 4 for forward) are not captured anywhere in the application.

Proposed Solution

Add a document-level mousedown event listener in the WebView to detect button 3/4 and invoke the existing GoBack/GoForward navigation logic:

  1. Inject a global JavaScript listener for mousedown events
  2. When event.button === 3 (back) or event.button === 4 (forward), call a Rust handler
  3. Reuse the existing HistoryManager navigation methods

Related Files

  • desktop/src/history.rs - History management (already implemented)
  • desktop/src/components/content/file_viewer.rs - WebView event handling
  • desktop/src/menu.rs - Menu handler for GoBack/GoForward
  • desktop/src/components/header.rs - UI button handlers

Notes

  • Keyboard shortcuts use muda's Accelerator which only supports keyboard Code, not mouse buttons
  • Trackpad gestures may require OS-level event handling (separate from this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions