Skip to content

Conversation

@emilk
Copy link
Owner

@emilk emilk commented Dec 22, 2025

This adds Ui::interact_opt which is a version of Ui::interact that lets you specify that if this widget already exists, it should be moved to the top of the interaction stack.

This lets you easily more easily "read a response from the future", by simply calling interact twice, instead of calling Context::read_response.

@emilk emilk added the egui label Dec 22, 2025
@github-actions
Copy link

github-actions bot commented Dec 22, 2025

Preview available at https://egui-pr-preview.github.io/pr/7805-emilkmove-interaction-to-top
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@emilk emilk merged commit 1fdc741 into main Dec 22, 2025
46 checks passed
@emilk emilk deleted the emilk/move-interaction-to-top branch December 22, 2025 20:34
Comment on lines +197 to +199
layer_widgets.remove(*idx_in_layer);
*idx_in_layer = layer_widgets.len();
layer_widgets.push(*existing);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layer_widgets.remove changes the index of the following widgets in this layer, meaning they now have the wrong index in the by_id map 😕

This should be the cause of #7812

emilk pushed a commit that referenced this pull request Jan 5, 2026
* closes #7812
* related #7805

That pr introduced a bug that caused a mismatch in the `by_layer` /
`by_id` widget rects. This should fix it by updating the index of all
following widgets. Not super pretty and efficient, but I'm not sure if
there's a better way.

Maybe we could also just leave a "tombstone" / duplicate there in the
by_layer map so we don't need to update the indexes?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants