Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup menu and pickers doesn't capture the input used to close it #5189

Open
abey79 opened this issue Sep 30, 2024 · 3 comments
Open

Popup menu and pickers doesn't capture the input used to close it #5189

abey79 opened this issue Sep 30, 2024 · 3 comments
Labels
bug Something is broken egui rerun Desired for Rerun.io

Comments

@abey79
Copy link
Collaborator

abey79 commented Sep 30, 2024

One can close popup menus and, e.g., the colour picker by clicking outside of it or hitting escape. Unfortunately, these inputs are not captured and thus potentially have an unwanted secondary effect.

In the case of rerun, escape will have the effect of deselecting whatever is currently selected, and the click will be processed by whatever happens to be under the mouse cursor (often, the view, which again leads to deselection).

color_picker.mp4
@abey79 abey79 added bug Something is broken egui rerun Desired for Rerun.io labels Sep 30, 2024
@abey79 abey79 changed the title Color picker doesn't capture the input used to close it Popup menu and pickers doesn't capture the input used to close it Sep 30, 2024
@emilk
Copy link
Owner

emilk commented Sep 30, 2024

This is by design (though arguably not good design). The thinking (within egui) is: pressing escape should escape everything. Otherwise what it escapes would depend on the order of which the UI is laid out, which is not obvious to a user ("why did A close instead of B?").

@abey79
Copy link
Collaborator Author

abey79 commented Sep 30, 2024

What is the "correct" way to opt-out of a popup menu then?

Otherwise what it escapes would depend on the order of which the UI is laid out, which is not obvious to a user ("why did A close instead of B?").

Perhaps naively, I'm expecting popup-menu/picker to be modal, so (1) they may not have sibling areas—only parent, over which they have precedence and (2) they may have zero or one "child" modal (e.g. a sub-menu), which would have precedence. In this model, it feels quite natural in how keystroke would be captured. Surely I'm missing dozen of edge cases and assorted implementation trickeries here, though.

pressing escape should escape everything.

My mental model doesn't conform to that. If have a stack of "modal things" open, I'm expecting to get out of it by hitting escape as many times as the number of modal things that are opened.


Related:

abey79 added a commit to rerun-io/rerun that referenced this issue Sep 30, 2024
#7548)

### What

This PR attempt to make the "deselect-on-ESC" less aggressive and avoid
triggering it when the ESC keystroke was used to close some other UI
element.

Work around for:
- emilk/egui#5189

#### Supported

- any popup menu (including color picker)
- context menu
- modals

#### TODO

- rerun menu (haven't found an easy way yet)

#### Not supported

- tooltip (on purpose, these disappear by themselves)

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7548?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7548?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7548)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
@emilk
Copy link
Owner

emilk commented Sep 30, 2024

Switching all i.key_pressed(Key::Escape) to use consume_key instead might be the right solution, we just need to be careful to do it in the right place so that:

  • Pressing escape closes all Menu:s (not just the innermost submenu)
  • Pressing escape closes the innermost popup (if nested)
  • …?

@emilk emilk added this to the Next Major Release milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui rerun Desired for Rerun.io
Projects
None yet
Development

No branches or pull requests

2 participants