Repository navigation
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/8944-retain-unconsumed-input-across-discard View snapshot changes at kitdiff |
simzy39
marked this pull request as ready for review
November 25, 2026 05:21
A discarded pass dropped input that no widget had accepted. Key, text, IME, clipboard, and accesskit events now remain for the next pass until a handler accepts or consumes them. Pointer, wheel, zoom, and modifier events are still applied as the pass starts. Unused scroll is carried as smooth_scroll_delta. InputState::events is an Events list. Acceptance stays on each event through removal, insertion, reordering, and the other list edits. Identical values stay distinct. key_pressed, key_released, and num_presses only look. A handler that acts calls accept_key or consume_key. One navigation key is applied per pass. An Escape that already cleared focus is accepted. The wheel smoother steps once per frame.
simzy39
force-pushed
the
retain-unconsumed-input-across-discard
branch
from
November 25, 2026 07:23
bf2c70f to
cfbc5f3
Compare
Button styling reads the previous pass before the widget is allocated. That read goes through get_response. Removing the click there dropped it before the response the caller keeps was built, so a button click stayed false. The click is reported on every read this pass and accepted when the widget is registered, so a discarded pass does not replay it.
simzy39
marked this pull request as draft
November 25, 2026 09:58
Contributor
Author
|
What remains outstanding
|
…ling - Preserve `keys_down` and key `repeat` flags when replaying a partial subset of `Event::Key` events after a discarded pass, avoiding stuck keys (accepted release or non-replayed `WindowFocused(false)`) and dropped held keys (accepted subsequent press). - Replace per-instance `Events` IDs with globally unique monotonic `EventId`s so whole-collection replacement cannot let stale navigation or Escape IDs match unrelated events; expand `Events` collection conveniences (`new`, `with_capacity`, `capacity`, `reserve`, `as_slice`, `into_vec`, `From<Events> for Vec<Event>`, `AsRef`, `Borrow`, `FromIterator`, `IntoIterator`, slice `Index`, `PartialEq`). - Avoid accepting `Space`/`Enter` or AccessKit `Click` activations during observational `read_response`/`Ui::response` reads, accepting them only when `create_widget` registers the widget. - Accept applied AccessKit `Action::Focus` requests so a discarded pass does not replay them over a later focus change, while leaving focus requests for unknown widgets unaccepted for the next pass. - Add `InputState::accept_key_releases`, update docs and `examples/keyboard_events`, and add targeted regression tests.
simzy39
marked this pull request as ready for review
November 26, 2026 02:38
This branch has not been deployed
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.
Closes #8942
A discarded pass previously lost unhandled input before the next pass. This PR preserves unaccepted key, text, IME, clipboard, and AccessKit events in their original order.
Pointer, touch, wheel, zoom, modifier, and window-focus events are already incorporated into input state and are not replayed. Remaining smooth scroll input is carried as
smooth_scroll_delta.Implementation
InputState::eventsis nowEventsinstead ofVec<Event>. Acceptance follows individual events through list mutations (remove,swap_remove,insert,retain,swap,reverse,rotate_*,sort_*,dedup*,drain,split_off,append,splice,truncate). Identical event values retain distinct identities.EventId), so replacing the entireInputState::eventscollection (Events::from,core::mem::take,FromIterator, serde) cannot let stale navigation or Escape ids match unrelated events. Replacing an individual event (including viaIndexMutoriter_mut) assigns a fresh unaccepted identity.key_pressed,key_released, andnum_pressesremain observational.accept_key,accept_key_presses,accept_key_releases,accept_event,accept_index, andaccept_accesskit_actionkeep events visible during the current pass while excluding them from replay;consume_*methods remove them immediately.Event::Keyevents do not mutatekeys_downor recomputerepeat, preserving persistent keyboard state from pass 0 even when only a subset of key events is replayed (e.g. an accepted release, an accepted subsequent press, or a non-replayedWindowFocused(false)).Space/Enter) and AccessKitAction::Clickwidget activations are accepted only whencreate_widgetregisters the widget, not during observationalread_response/Ui::responsequeries. This prevents preliminary styling and popup reads from swallowing clicks while ensuring delivered clicks are not replayed.Action::Focusrequests are accepted so a discarded pass does not replay them over a later focus change; focus requests for widgets not yet in the focus cache remain unaccepted for the next pass.egui_extras's datepicker, andexamples/keyboard_eventsaccept or consume handled events. The wheel smoother advances only once per frame.Breaking changes & migration
InputState::eventschanges fromVec<Event>toEvents.Eventsdereferences to[Event]and implements slice/index reads (Index<I: SliceIndex<[Event]>>),AsRef<[Event]>,Borrow<[Event]>,PartialEqwithVec<Event>/[Event]/&[Event],From<Vec<Event>>,From<Events> for Vec<Event>,into_vec(),FromIterator<Event>,IntoIterator(owned,&,&mut),Extend<Event>, and commonVecmethods (new,with_capacity,capacity,reserve,as_slice,push,pop,insert,remove,swap_remove,clear,truncate,retain,swap,reverse,rotate_left,rotate_right,sort_*,dedup*,drain,split_off,append,splice,iter_mut).&mut Vec<Event>or&mut [Event]needs to useEventsmethods directly (or convert withinto_vec()/Events::from).events[i] = ...) oriter_mut()resets those slots to fresh unaccepted events; useevents.swap(a, b)orevents.retain(...)to preserve acceptance across reorders or removals.key_pressed,key_released,num_presses, or raweventsloops) should accept (accept_key,accept_key_presses,accept_key_releases,accept_event,accept_index) or consume (consume_key,consume_shortcut,remove_event) the handled events so they do not run again on a subsequent pass afterrequest_discard.Validation
On final commit
9f7580a9:egui: 158 library unit tests, 3drop_zone+ 1imeintegration tests, and 189 doctests passed (1 ignored).egui_extras: 18 library unit tests, 4table_sizingintegration tests, and 7 doctests passed.scripts/lint.py,cargo fmt --all -- --check,cargo doc(public and--document-private-items,RUSTDOCFLAGS="-D warnings"), feature-matrix checks (--no-default-features,--no-default-features --features serde,--all-features), andcargo clippy(debug foregui,egui_extras,keyboard_events; release foregui,-D warnings) all passed.9f7580a9): all 25 technical checks passed (Run tests,Format + check,Check Windows,Check wasm32 + wasm-bindgen,Check wasm32+atomics,android,ios,build,typos,taplo,cargo-shear,check-binary-files,check-source-branch, and all 11cargo-denytargets; only the maintainerlabelcheck fails pending a label).modeler-desktopagainst the final PR changes:modeler-desktopcompiled cleanly withEvents, its existing regression test expecting dropped clicks failed specifically becausepress.undo.clicked()is nowtrueon the kept pass, and a workaround-free test ofhistory_bar(without SuperBlender'ssettle_history_clickorhistory_target_of_eventsworkaround) confirmed the Undo AccessKit click fires once both when omitted on pass 0 and when built on both passes. SuperBlender's files were restored unchanged afterward.cfbc5f38against upstream35925b9, coveringbegin_pass,key_pressed,num_presses, andretain; median of 3 runs, within run-to-run noise):cfbc5f38)35925b9)Remaining limitations / out of scope
smooth_scroll_delta).Action::Focusrequest still only targets widgets already infocus_widgets_cachefrom the previous pass (across a discarded pass, an unmatched focus request remains unaccepted and applies once the widget is registered).Arrow*/Tab) is applied per pass; earlier navigation keys in the same batch replay only when another pass runs.AI assistance (OpenAI ChatGPT, xAI Grok, and Google Gemini / Antigravity) was used during investigation, implementation, testing, and review.