From f154704ad0563ab589dbd2cd556cabeed58f8257 Mon Sep 17 00:00:00 2001 From: ANSI TV Admin Date: Wed, 11 Nov 2026 12:04:09 -0800 Subject: [PATCH 09/24] SyncTERM: click selects, second click or double-click opens Applies after `pointer-hide.patch`. Stock behaviour opened a list entry on a single click (UIFC's click-to-activate), so a dialer entry connected the moment it was touched. Now a click on an unselected row selects it; a click on the selected row, or a double-click, activates it (`ui_list.wren`, with a unit test). The dialer's first click into the unfocused pane focuses it and selects the row under the pointer without opening it (`main_menu.wren`). Verified in the live dialer under Xvfb: one click on an entry highlights it and stays in the dialer, the second connects, a double-click connects, and a click on the highlighted row of the unfocused pane only focuses. --- src/syncterm/scripts/auto/menu/main_menu.wren | 8 +++++++- src/syncterm/scripts/ui_list.wren | 13 ++++++++----- src/syncterm/scripts/ui_list_test.wren | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/syncterm/scripts/auto/menu/main_menu.wren b/src/syncterm/scripts/auto/menu/main_menu.wren index 2fce0e17..11c5a57a 100644 --- a/src/syncterm/scripts/auto/menu/main_menu.wren +++ b/src/syncterm/scripts/auto/menu/main_menu.wren @@ -241,7 +241,13 @@ class MainList is ListView { event.event == Mouse.button1Click) { var active = parent != null && parent.focused var activate = _onFocus.call() - if (!active && activate != true) return true + if (!active && activate != true) { + // The click that focuses this pane also picks the row under the + // pointer -- it only selects; a second click opens it. + var idx = scrollTop + (event.startY - bounds.y) + if (idx >= 0 && idx < count) selected = idx + return true + } } if (event is MouseEvent && parent != null && !parent.focused && (event.event == Mouse.wheelUpPress || diff --git a/src/syncterm/scripts/ui_list.wren b/src/syncterm/scripts/ui_list.wren index f217bcef..8472ba0e 100644 --- a/src/syncterm/scripts/ui_list.wren +++ b/src/syncterm/scripts/ui_list.wren @@ -655,7 +655,8 @@ class ListView is Widget { // UIFC list actions occur on a completed button-1 click. Press // and drag events fall through to the screen-selection path. - if (e != Mouse.button1Click) return false + var dbl = e == Mouse.button1DblClick + if (e != Mouse.button1Click && !dbl) return false if (overSeparator) return true if (overScrollbar) { @@ -672,13 +673,15 @@ class ListView is Widget { var idx = _scrollTop + (me.startY - bounds.y) if (idx >= 0 && idx < _items.count) { - selected = idx - // Click-to-activate: matches UIFC's `ulist`, which returns - // immediately on a row click rather than waiting for Enter. + // A click on a row that is not selected only selects it; a click + // on the row that already is -- which is also what the second + // half of a double-click is -- activates it, as Enter would. // Fires only on full clicks (not the initial press of a // potential drag) so a click-then-drag for text selection // doesn't fire onSelect prematurely. - if (_onSelect != null && selectedItem != null) { + var already = idx == _selected + selected = idx + if ((already || dbl) && _onSelect != null && selectedItem != null) { _onSelect.call(_selected, selectedItem) } return true diff --git a/src/syncterm/scripts/ui_list_test.wren b/src/syncterm/scripts/ui_list_test.wren index dea642d6..384d2040 100644 --- a/src/syncterm/scripts/ui_list_test.wren +++ b/src/syncterm/scripts/ui_list_test.wren @@ -61,6 +61,7 @@ class UiListTest { testKeyEnterFiresOnSelect_() testKeyEnterNoCallback_() testMouseClickSelectsRow_() + testMouseClickSelectsThenActivates_() testMousePressDoesNotSelectRow_() testMouseHoverIgnored_() testMouseClickScrollbarTrackBottom_() @@ -413,6 +414,22 @@ class UiListTest { "ListView.handle Mouse: row click selects that row") } + static testMouseClickSelectsThenActivates_() { + var l = makeList_(3) + l.bounds = Rect.new(1, 1, 10, 5) + var fired = [] + l.onSelect = Fn.new {|i, item| fired.add(i) } + l.handle(MouseEvent.new(Mouse.button1Click, 5, 3, 5, 3)) + check_(l.selected == 2 && fired.count == 0, + "ListView.handle Mouse: click on an unselected row only selects") + l.handle(MouseEvent.new(Mouse.button1Click, 5, 3, 5, 3)) + check_(fired.count == 1 && fired[0] == 2, + "ListView.handle Mouse: click on the selected row activates") + l.handle(MouseEvent.new(Mouse.button1DblClick, 5, 2, 5, 2)) + check_(l.selected == 1 && fired.count == 2 && fired[1] == 1, + "ListView.handle Mouse: double-click activates any row") + } + static testMousePressDoesNotSelectRow_() { var l = makeList_(3) l.bounds = Rect.new(1, 1, 10, 5) -- 2.47.3