Repository navigation
Select a cell when the button goes down, not on release - #909
marcoarnulfo wants to merge 1 commit into
Conversation
|
Thanks @marcoarnulfo, and thanks for picking this up so quickly (and for #869 too)! I built this branch (427dcac) on Windows 11 at 150% scaling and re-ran the real-mouse tests from the issue against it and against v0.6.1. Same method as before:
So the long-press case (0.8 s or longer, which your tests don't cover since it needs real idle time with no frames) is fixed on Windows too, and nothing regressed in the cases I tried. I didn't test the fill-handle corner or drawing tools. |
|
Thank you for the thorough run on real hardware, that table is great. Especially the long-press rows: those need real idle time, which my harness tests can't reproduce, so it's good to know they're fixed too. |
|
Thanks for this — I hit the same lag on macOS and had a local patch for it before finding #900, so a few notes from that work in case they are useful. Presses that still wait for release here. The press path requires
In my patch these also act on press. The only header presses I had to leave on drag/release were resize edges and a press on an already selected column header (it may become a column move). Page Layout view — worth a check, I have not run this branch. A header/footer zone lies inside the cell area, so Double-click. Keeping double-click-to-edit on release is the right call: I first opened the editor on the second press, and the release over the grid then took keyboard focus away from it, so typing went nowhere. Happy to send the header part as a small follow-up PR once this lands, if that is welcome. |
|
Thanks @anton-belkin, these notes are really useful. I'm checking the Page Layout header/footer zones on this branch now and will exclude them from the press path if a press there selects the cell underneath. And yes please on the header follow-up, that would be very welcome. |
|
@anton-belkin I checked the Page Layout case: on this codebase Also, I see #927 by @echelon covers #900 together with the fill-handle and whole-column reference work. Happy to close this one in favour of it if that's simpler for you, just say so. |
|
You're right, thanks for checking — On #909 vs #927 that's the maintainers' call. I'll base the header follow-up on whichever one lands. |
|
No noise at all, thanks for digging into it @anton-belkin. Sounds good, happy to help with the header follow-up whichever lands. |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: a cell is selected when the button goes down, not on release. A press on a plain cell selects it at once, as Excel does, and dragging extends from it; presses on button-like targets, objects, the fill handle or the move border, and presses while editing, are still decided below on drag or release. Excel selects on mouse down, so the oracle fits, and the usual defect of this change is that a press on a target that should not select (a header, a hyperlink, a scroll bar) does. The condition lists the exceptions, and a test for each is the proof. Touch screens, where a press can be the start of a scroll, may want selection on release; that case should be considered. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
Fixes #900.
The grid only decided a press from
drag_started()orclicked(), so nothing happened while the button was down, and a press whose movement and release arrived in the same frame (past the click distance, but never recognised as a drag) selected nothing. A press on a plain cell now selects it right away (Shift extends, Ctrl/Cmd adds an area) and entersDrag::Selectwith that cell as the anchor, so dragging extends from it as before. Presses on the outline buttons, filter and list arrows, objects, freeze handles, the fill handle and the move border, and presses while editing, keep going through the existing path, so they still act on drag or release. Following a hyperlink, toggling a checkbox and double-click-to-edit stay on release, as in Excel. The selection code moved into a smallselect_pressed_cellhelper shared by both paths.Two things to know: with a drawing tool active the press still selects on release, as before. And since the cell is now selected on the way down, its fill handle is already there when the button comes up, so a click on the last few pixels of the bottom-right corner of a cell that wasn't selected before lands on the handle (no double-click-to-edit or link there). Happy to adjust either.
Validation:
selection::a_press_selects_the_cell_before_the_release: fails on main (A1 still selected while the button is down on C3), passes hereselection::a_press_that_moves_within_the_cell_selects_it: fails on main (move + release in one frame leaves A1 selected), passes hereselection::pressing_a_filter_arrow_or_an_outline_button_keeps_the_selection: guards the button-like targets; dropping the filter-arrow exclusion makes it failcargo test -p gridcraft-ui-eguifor selection, interaction, outline, filter_list_scroll, fill_handle_double_click, header_column_drag, freeze_handles, chart_resize, cell_pictures, merged_cells, right_to_left, popup_dismissal, text_box_editing and the other pointer-driven test filescargo clippy -p gridcraft-ui-egui --all-targets -- -D warnings,cargo fmt --all -- --check