Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pointer gestures and profiles

What the wheel, a trackpad’s two fingers, a pinch and each mouse button do on a canvas is not one fixed rule: photo applications zoom with the wheel, document tools scroll with it, node editors pan with the middle button. egui-pop ships five pointer profiles and lets the user pick one, then change any gesture in the shortcuts editor, as a keyboard shortcut is changed. The study behind it, with the survey of fifteen applications, is design/pointer-gestures.md.

Gestures are keymap bindings

A chord’s key may be a pointer gesture, with the usual modifiers (Ctrl is Cmd on macOS):

GestureWhat it is
Wheela mouse wheel’s notches (line units)
Scrolla smooth scroll in points: a trackpad’s two fingers, a free-spinning wheel
Pinchtwo fingers apart or together (a browser sends a trackpad’s pinch the same way)
PrimaryClick, MiddleClick…a button pressed and released without moving
PrimaryDoubleClick…a double click
PrimaryDrag, MiddleDrag, SecondaryDrag…a button held while the pointer moves

Buttons are Primary, Secondary, Middle, Back and Forward: the logical buttons (a left-handed setup swaps them in the system). A pointer chord stands alone, never in a sequence: Ctrl+Wheel, Shift+MiddleDrag, Pinch. It is bound to a gesture command in the scope of a canvas kind:

ScopeCommands
surface:canvas.image (the image viewport)gesture.image.zoom (holding at fit and 100 %), zoom_free, pan, pan_x, pan_y, zoom_cycle (100 %, 200 %, fit), fit, zoom_toggle (fit or 100 %)
surface:canvas.graph (the node graph)gesture.graph.zoom, pan, pan_x, pan_y, fit
surface:widget.value (sliders)gesture.value.step (its wheel’s modifiers step a slider without the focus), fine and coarse (their drag’s modifiers: ten times finer or coarser, for drags, arrows and the wheel), panel (its wheel’s modifiers leave the wheel to the panel), reset (a primary click with its modifiers, Ctrl+PrimaryClick for one, puts the value back to its default; bound by no shipped profile)
surface:widget.sections (stacked sections)gesture.sections.pull (a drag on a boundary or a title moves the sections below as a block; its keys also make the arrows on a boundary do so, sections.md)
surface:workbench.palette (a floating palette’s drag)gesture.workbench.dock (its keys, held while a palette is dragged, dock it or join another palette, or keep it floating, as input.dock_drag says; workbench.md)

The keymap’s layers, removals, conflicts and resolution trace apply unchanged (plugins.md); the key dispatcher never sees a pointer chord: canvases read the resolved table instead.

The six profiles

A profile is a pointer-profile document (in crates/egui-pop-model/profiles/): bindings for the default layer, the options it gives its default for, the modifiers egui’s own scrolling follows (egui::InputOptions), so plain scroll areas agree, and, where they differ from the drag’s, the modifiers of a value’s arrow keys (value_keys). Each profile named after an application follows that application; where it has no equivalent the gesture is left unbound.

Document (default)darktablePhotoshopLightroom ClassicBlender / node editorsTrackpad
Wheel on the imagepanszooms (Ctrl: no stops)pans—zoomspans
Ctrl + wheel on the imagezoomszooms without stopspans sidewayszoomspans sidewayszooms
Shift + wheel on the imagepans sidewayspans sideways——pans up and down—
Alt + wheel on the image——zooms———
Two fingers / a pinchpan / zoompan / zoompan / zoompan / zoompan / zoompan / zoom
Primary drag on the imagepanspanspanspanspanspans
Middle dragpanspans——pans (graph: also a secondary drag)—
Middle click on the image—100 %, 200 %, fit————
Click on the image———fit or 100 %——
Double click on the imagefitsleaves the view—leaves the viewfitsfits
Wheel on the graphpanszoomspanspanszoomspans
Wheel over a sliderscrolls the panelchanges the valuescrolls the panelscrolls the panelscrolls the panelscrolls the panel
Steps a slider without the focusAlt + wheelthe wheel; Ctrl+Alt + wheel scrolls the panel——Ctrl + wheelCtrl + wheel
Finer / coarser dragCtrl / ShiftCtrl / ShiftAlt / ShiftShift / —Shift / CtrlCtrl / Shift
Finer / coarser arrowsas the dragas the dragas the dragAlt / Shiftas the dragas the drag
Pulls stacked sections as a blockCtrl + dragCtrl + dragCtrl + dragCtrl + dragCtrl + dragCtrl + drag

In every profile a drag with Space held pans the image and the graph, Escape cancels a drag, a primary drag on a handle moves it and the wheel over a handle adjusts it. The finer and coarser modifiers apply to a slider’s drag, its wheel and, unless the profile gives them their own, its arrow keys: Lightroom Classic makes a Shift drag finer but Shift with the arrows coarser, and has no coarser drag. Neither Adobe application has a node graph: both profiles take Photoshop’s canvas wheel there. Lightroom’s click on the image toggles fit and 100 %, and a double click leaves the view, as its Loupe goes back to the Grid: its first click toggles the zoom, its second press only leaves. The id adobe, from before the split into Photoshop and Lightroom Classic, still works and names lightroom; pickers do not list it. “Leaves the view” is a signal (Signal::Leave): the application decides what it means (darktable goes back to the lighttable).

An application picks its profile with AppBuilder::pointer_profile ("darktable"); the user changes it in the settings (input.pointer_profile). Two options follow the profile unless set: input.slider_wheel (guarded: the wheel scrolls the panel and steps a slider with the focus or the step modifiers; value: it changes the slider under the pointer) and input.image_double_click (fit, leave, nothing). A third, knob_drag, is in each profile’s options (vertical, horizontal, both, circular; vertical in every shipped profile): how a drag turns a knob that does not say (Knob::drag), carried to the widgets in the sliders’ Gestures. input.dock_drag (profile, modifier-docks, modifier-floats, dwell; the profile’s options.dock_drag, modifier-floats in Photoshop’s, modifier-docks in the others) says what a plain drag of a floating palette does; an application picks its default with AppBuilder::dock_drag (workbench.md). input.wheel_device settles what sends wheel events: auto takes lines for a mouse wheel and points for a trackpad, mouse and trackpad say it outright (some mice send points). input.wheel_speed multiplies how far a notch goes, in scroll areas and on the canvases that read it through wheel_inputs, zoom included; what comes in points is left alone, whichever device sends it, and a slider’s wheel still steps once a notch. Its default is 1, or the system’s lines a notch over 3 when the application gives them with AppBuilder::system_wheel_lines (egui_pop_platform::wheel_lines::read, Windows only).

use egui_pop::api::{App, DefaultPlugins};

let app = App::builder()
    .plugins(DefaultPlugins)
    .pointer_profile("darktable")
    .build(&egui_pop::egui::Context::default())
    .unwrap();
assert_eq!(egui_pop::api::pointer::profile_id(app.handle()), "darktable");

A profile also gives the keys of the canvas navigation commands (view.fit, view.frame_selection, view.zoom_in, view.zoom_out, view.zoom_100, view.pan_*, view.hand), after its application: Photoshop’s Ctrl+1 for 100 % and Ctrl+0 to fit, darktable’s Alt+1 and Alt+3, Figma’s Shift+1 and Shift+2 in Document, Blender’s .. They are the view_keys of the profile document, loaded with its gestures into the keymap’s default layer, active while a canvas is in use (canvasActive && !fileBrowserFocused && !textInputFocus && !modalOpen): the shortcuts editor lists them under View and the user rebinds them there. The full table is in the navigation study.

"view_keys": {
  "view.fit": ["Home", "Ctrl+0"],
  "view.zoom_100": ["Ctrl+1"]
}

Drag cursors

What a drag does decides its cursor, not the widget it starts on: a widget names the drag kind of each of its drags (egui_pop::model::pointer::DragKind) and shows its cursors with egui_pop::core::pointer::drag_cursor(&response, kind) (or UiPop::drag_cursor). The drag cursor shows every pass the response is dragged, wherever the pointer is: egui resets the cursor each pass, and the pointer leaves a widget it drags. A widget following a drag of its own (a state rather than one response) calls hold_drag_cursor(ctx, kind), and hover_drag_cursor(ctx, kind, clicks) over what it hovers itself.

The hover rule

Hovered, before any drag, a draggable shows its drag cursor only when dragging is its only action: nothing happens on a click or a double click on it. Where a click does something (select, set a value, move the playhead, open, add a point, deselect), the arrow stays until the drag starts; then the element shows its drag cursor as any other. This is the hover policy only-action (HoverPolicy::OnlyAction), every kind’s default but text’s (always: an I-beam over text). Whether an element clicks is read from its response’s sense (Sense::click), unless the widget says so (.clicks(false) on a splitter whose click only takes the focus).

ElementHoveredDragged
splitters, side area and flyout edgescolumn resizecolumn resize
palette edges, dialog gripsresizeresize
item handlesmovemove
the navigator’s and the graph minimap’s view framemovemove
the histogram (drag only)horizontal resizehorizontal resize
text (the code editor, the terminal)I-beamI-beam
outside the view frame (a click jumps there)arrowmove
timeline lanes, a DJ deck’s content (a click moves the playhead)arrowclosed hand
timeline clips, markers and trim handles, graph nodes, bands (a click selects)arrowmove, resize
sliders, the curve editor, the colour wheels (a click sets a value, adds a point)arrowhorizontal resize, crosshair
the compare view’s panes (a double click fits)arrowclosed hand
KindHoverDragWhere
panopen handclosed handthe graph’s canvas (a pan), the compare view’s panes, a timeline’s middle drag
scrubopen handclosed handa fixed playhead’s content (DJ decks)
movemovemovegraph nodes, stacks and group titles, timeline clips, bands, item handles, the navigator’s and the graph minimap’s view frame
carryarrowclosed handa port’s or a wire’s end, a tree’s drag and drop, a palette’s tab
valuearrowhorizontal resizesliders, range sliders, the video’s scrub bar, a timeline’s scrub
pointarrowcrosshairthe curve editor, the colour wheels
selectarrowcrosshairrubber bands (the graph, the thumbnail grid), a timeline’s Shift+drag range
textI-beamI-beamthe code editor’s text, the terminal
resize-horizontal, resize-vertical, resize-nw-se, resize-ne-swresizeresizepanel, palette and window edges, dialog grips, timeline markers and trim handles, the histogram
split-columns, split-rowscolumn resize, row resizethe samesplitters between panes, side area and flyout edges

The image viewport keeps its own tool cursors (cursors.md); egui_stack’s dock separators and tabs, and the stacked sections’ boundaries, set theirs in egui_stack; a window’s frame hands its moves and resizes to the system.

Three levels

Everything above can be changed, at three levels; the most specific one wins, and what a level leaves out is the level below’s:

  1. The widget, in code: the value drag_cursor returns is applied when it is dropped, at the end of the statement, and changes first:

    pointer::drag_cursor(&response, DragKind::Move)
        .hover(egui::CursorIcon::Grab)          // the cursor hovered
        .dragging(egui::CursorIcon::Grabbing)   // the cursor dragged
        .hover_policy(HoverPolicy::Always);     // only-action, always, never
  2. The pointer profile: drag_cursors, by kind, a CSS cursor name for hover, drag, and a policy (an empty or unknown name, no policy, keep the level below’s; PointerMap::drag_cursor_over resolves them). Blender / node editors keeps the arrow over what can be panned or moved; a profile could also show the open hand over a DJ deck’s content although a click there seeks:

    "drag_cursors": {
      "pan": { "hover": "default" },
      "move": { "hover": "default" },
      "scrub": { "policy": "always" }
    }
    

    (Blender’s are the first two.)

  3. The kit: drag-cursor.<kind>.hover, .drag and .policy, string tokens, so that a kit restyles them without code. The default kit gives every kind’s own (kit.md); a name that is not a CSS cursor, or a policy that is not one of the three, is reported among the kit’s problems and the default kept:

    drag-cursor:
      pan:
        hover: {$type: "string", $value: "all-scroll"}
        policy: {$type: "string", $value: "always"}
    

egui_pop::core::pointer::resolve_drag_cursor(ctx, kind) gives the kit’s cursors under the profile’s; drag_cursor_icons the same as egui’s cursors.

The gallery’s drag_cursors test drives each draggable and fails if one shows the arrow while it is dragged, or a cursor hovered other than the rule’s; one test per level shows it wins over the level below.

Changing a gesture

The shortcuts editor (Ctrl+,, then Keyboard shortcuts) lists every gesture command under Pointer, says which profile is in force and how many of its gestures the user changed, and has a filter showing the gestures alone. Each trigger of a gesture has its own removal; Add a gesture opens a pad on which the gesture is done (the wheel, a pinch, a click, a double click or a drag, holding its keys), then used. The reset takes the profile’s triggers back. Conflicts are reported per canvas scope, as for keys. On Linux, Alt with a drag or the wheel comes with a warning: some window managers take it.

The user’s changes are user-layer bindings, saved in the keymap document (version 3), and stay over the profile. When the profile changes and some exist, a dialog asks whether to keep them on the new profile or drop them (pointer.overrides, { "value": "keep" | "drop" }). AppHandle::rebind_gestures changes a gesture’s triggers from code.

What canvases read

The application publishes the table in force to its context after each change (egui_pop::core::pointer::map); without an application, canvases follow the default profile. A canvas of an application’s own reads the wheel raw with egui_pop::core::pointer::wheel_inputs (unit and modifiers kept: egui merges a pinch with Ctrl and the wheel once it smooths the delta) and looks each gesture up in its scope (PointerMap::command). The image viewport’s Gestures and the graph’s take their pointer part from it (viewport::gestures::ViewGestures), sliders their modifiers (core::slider::Gestures::from_map), stacked sections whether a drag pulls (core::sections, as long as it lasts, so that a key pressed or released changes the mode from there); set_gestures still sets either outright.

The image viewport and the graph give a hint while the pointer is over them: what the pointer does with the keys held now (Wheel: pan · PrimaryDrag: pan, with Ctrl Wheel: zoom), in their output (ViewportOutput::hint, GraphOutput::hint) and for a status line (egui_pop::core::pointer::hint_now). The viewport shows the hand when the keys held make a drag pan where a plain drag would not.

The canvas in use

egui_pop_core::canvas says which canvas (the node graph, the image viewport, a plot, an application’s own) the navigation commands go to. It belongs to the family “Pointer and canvas” (ADR 0027); it owns which canvas is in use and the commands waiting for it, and refuses the navigation model itself (the viewport crate’s egui_pop_viewport::navigation).

  • A canvas marks itself active each frame the pointer is over it or it has the keyboard (egui_pop_core::canvas::mark_active); egui_pop_core::canvas::active is the one marked this frame or the one before, last the one marked last however long ago.
  • The application’s view.* commands (view.fit, view.frame_selection, view.zoom_in, …) go through egui_pop_core::canvas::request to the canvas in use, else to the one marked last (where an agent’s command goes), or to one by id with request_to; the canvas takes them at its next frame (egui_pop_core::canvas::take). The canvasActive context key says whether one is in use, so the commands’ keys reach nothing else.
  • A canvas publishes its zoom (set_zoom, 1 is 100 %) for a zoom control to show; hand mode (hand, set_hand: a primary drag pans every canvas, for a pen) is shared by every canvas.
use egui_pop::core::canvas;
use egui_pop::egui;

fn my_canvas(ui: &mut egui::Ui, zoom: &mut f32) {
    let id = ui.id().with("my_canvas");
    let response = ui.allocate_response(ui.available_size(), egui::Sense::click_and_drag());
    if response.hovered() || response.has_focus() {
        canvas::mark_active(ui.ctx(), id);
    }
    for command in canvas::take(ui.ctx(), id) {
        if command == "view.zoom_in" {
            *zoom *= 2.0;
        }
    }
    canvas::set_zoom(ui.ctx(), id, *zoom);
}

A command sent when no canvas was ever marked is dropped (request answers false); commands a canvas does not know are its to ignore. Tier: Experimental, with the pointer gestures (“Pointer gestures and the canvas … profiles of input are not designed yet”, API stability). Tests: crates/egui-pop-viewport/tests/canvas_navigation.rs (the image takes the view commands and their keys and is the canvas in use, hand mode, each profile’s navigation keys) and navigation.rs; the module’s own contract (the canvas in use this frame or the one before, the one marked last, commands queued per canvas and taken once, a dropped command, hand mode, zoom per canvas) in crates/egui-pop-core/tests/canvas.rs.

A widget’s own secondary button

The secondary button opens a context menu everywhere by default, and a canvas may bind a secondary drag in its profile (Blender / node editors pan the graph with it). A widget that needs the right click for something else (a curve editor deleting a point, a swatch resetting its colour, a canvas of the application’s binding a right drag) claims it on its rect, each pass it is drawn (egui_pop::core::pointer::claim):

use egui_pop::core::pointer::claim::{self, SecondaryClaim};
use egui_pop::egui;

fn swatch(ui: &mut egui::Ui) {
    let r = ui.allocate_response(egui::vec2(24.0, 24.0), egui::Sense::click());
    claim::claim_secondary(&r, SecondaryClaim::new("Swatch").click("Resets the colour"));
    if r.secondary_clicked() {
        // reset the colour
    }
}

SecondaryClaim::click takes the click, drag the drag; a widget may take both. Where the button was pressed over a claim:

  • no context menu opens, neither one declared on a parent (menus::context_menu) nor egui-pop’s own (the graph’s, the status bar’s, a tree’s, the window’s system menu on the title bar); a menu drawn with egui’s Response::context_menu should go through claim::context_menu to obey claims, and code reading the click itself asks claim::opens_context_menu;
  • the canvas’s profile binding for that gesture does not fire (the image viewport’s secondary clicks and drags, the graph’s secondary drag), and a canvas of the application’s asks claim::claimed the same way.

A claimed click leaves the secondary drag to the canvas, and a claimed drag leaves the click to the menus. A claim counts for the pass it was made in and the next, so a parent that reads its response before its children are drawn sees them; a window or popup drawn above it hides it. The curve editor claims the secondary click, which deletes the point under the pointer.

What a claim says it does is kept as the widget’s use: the shortcuts editor lists the uses seen so far under Widgets’ own gestures (they are the widget’s, so not changed there), and claim::declare_use lists one before its widget is first drawn. The debug bridge’s pointer collector shows the profile in force, the hint, the claims in force (widget, rect, click and drag with what they do) and the uses.

The web

Ctrl and the wheel zoom a page, and a trackpad’s pinch arrives the same way: a web build takes them from the browser. Pass egui_pop::core::pointer::web_prevent_default as eframe’s WebOptions::should_prevent_default, and give the canvas touch-action: none in its page, as the gallery does.