Skip to content

feat: emit TextAction::Cancelled on Escape key press and expose on_escape callback for TextInput#1826

Open
phamsongnewl wants to merge 4 commits into
linebender:mainfrom
phamsongnewl:develop
Open

feat: emit TextAction::Cancelled on Escape key press and expose on_escape callback for TextInput#1826
phamsongnewl wants to merge 4 commits into
linebender:mainfrom
phamsongnewl:develop

Conversation

@phamsongnewl

Copy link
Copy Markdown

Summary

  • Add TextAction::Cancelled variant to TextAction enum, emitted when the Escape key is pressed in a TextArea.
  • Add on_escape callback builder to TextInput (xilem), mirroring the existing on_enter pattern.
  • Handle TextAction::Cancelled in TextInput's message dispatch to invoke the registered callback.

Changes

masonry/src/widgets/text_area.rs

  • New TextAction::Cancelled variant with doc comment.
  • Key::Named(NamedKey::Escape) handling that submits TextAction::Cancelled via ctx.submit_action.
    xilem_masonry/src/view/text_input.rs
  • New on_escape: Option<Callback<State, Action>> field.
  • TextInput::on_escape(F) builder method (matches on_enter signature).
  • TextAction::Cancelled handling in View::message — calls the callback or returns Stale.

Motivation

Escape is a universal cancel/dismiss gesture in desktop UIs. TextArea previously had no way to surface it to the view layer, forcing users to work around it at the event level.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants