Repository navigation
Widget kit crate: buttons commit on release (fixes #119) - #120
Merged
Merged
Conversation
Every control in the app fired its action from gpui's on_mouse_down, so a button "clicked" the moment it went down and sliding off could not cancel it. Native buttons commit on release over the control, which is what gpui's on_click implements. Add crates/ui (schist-ui): the palette, icons and tooltips moved out of the app, plus Button, IconButton, Checkbox, ListItem, Tab, Link and Swatch components that all act on release. They take plain handlers so cx.listener fits directly, implement Styled and ParentElement so callers can override their defaults, and offer consume_press for buttons that sit inside selectable rows. Convert the panels, dialogs, menus, style dialog, filter gallery and the photo gallery views to the kit. What starts a gesture keeps the press: canvas tools, sliders, drags, click-to-focus fields, right-click menus, row selection, tab switching, and menu/dropdown openers (native menus open on press, and a popup dismisses on the press outside it). Verified headlessly with xdotool: a press without release does nothing, a release off the control cancels, and a click acts. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #119.
Why
Every control in the app fired its action from gpui's
on_mouse_down, so a button "clicked" the moment it went down and sliding off could not cancel it. Native buttons (AppKit, UIKit, Win32, the web) commit on release over the control, which is exactly what gpui'son_clickimplements.What
crates/ui(schist-ui). The palette, icons and tooltips move out of the app (which re-exports them), joined byButton,IconButton,Checkbox,ListItem,Tab,LinkandSwatch. Every one acts on release (or Enter/Space when focused). They take plainFn(&ClickEvent, &mut Window, &mut App)handlers socx.listenerfits directly, and implementStyledandParentElementso a caller's refinements override the defaults.consume_press()covers buttons that sit inside selectable rows, replacing the hand-rolledstop_propagationcalls.docs/architecture.mdgains a short "Chrome" section stating the rule.Verification
cargo fmt --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspaceall pass.Worth a glance
Button's hover only changes the fill.🤖 Generated with Claude Code