Skip to content

feat(ui): paste the selected clip with Enter and hide on Escape - #8

Open
hadoukim wants to merge 3 commits into
Walkercito:mainfrom
hadoukim:feat/keyboard-paste-and-escape
Open

feat(ui): paste the selected clip with Enter and hide on Escape#8
hadoukim wants to merge 3 commits into
Walkercito:mainfrom
hadoukim:feat/keyboard-paste-and-escape

Conversation

@hadoukim

Copy link
Copy Markdown

What

  • Enter pastes the selected clip. The list's row-activated signal
    routes the keyboard-focused row through the same copy path as a click,
    so after navigating with ↑/↓ you can paste with Enter.
  • Escape hides the window, from both the search entry and the list.

How

  • Gtk::ListBox::signal_row_activatedcopy() (deferred to an idle,
    like ClipCard does on click, so the row isn't torn down mid-event).
  • set_activate_on_single_click(false) so activation doesn't double up
    with ClipCard's own click gesture (copy / Ctrl-pin).
  • A capture-phase EventControllerKey on the content box catches Escape
    before the search entry's clear-on-Escape and hides the window.

Testing

Built with the debug preset (clean under -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Werror) and run against a live GNOME/Wayland
session: ↑/↓ navigate, Enter pastes the highlighted clip, Escape closes.

Enter now pastes the clip the arrow keys landed on: the list's
row-activated signal routes the focused row through the same copy path
as a click. Single-click activation is turned off so it doesn't double
up with ClipCard's own click gesture (copy / Ctrl-pin).

Escape hides the window, via a capture-phase key controller on the
content so it takes precedence over the search entry's clear-on-Escape.
@Walkercito Walkercito added the enhancement New feature or request label Jul 22, 2026
Enter typed mid-search hit the entry's own Return binding instead of
pasting, so the reported repro never worked. Handle the keys on a
capture-phase controller at the window, ahead of the focused child, and
make the list selection the cursor Enter acts on.

The key mapping moves to a pure key_action() policy that unit-tests
headless. Dialogs and popovers keep their own keys, a focused button
keeps Enter, copy() guards against the double activation ClipCard could
already emit, and hide() clears the filter on every exit path.

Closes Walkercito#7
Pinning recreates the card the cursor sits on, so the selection died with
it and apply_filter snapped the cursor to the top of the list. Remember
the selected content across the rebuild and put the cursor back on it.

Ctrl+click reaches GtkListBox as a selection toggle and can leave nothing
selected, which left the arrows dead until the next filter pass; they now
start at the top when there is no cursor to move.
@Walkercito

Copy link
Copy Markdown
Owner

I'm still testing to make sure everything's all right with the performance. I'll merge it soon 😅

@hadoukim

hadoukim commented Aug 1, 2026

Copy link
Copy Markdown
Author

I'm still testing to make sure everything's all right with the performance. I'll merge it soon 😅

Yeah no rush, thanks for working on it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants