emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.57k stars 1.56k forks source link

Modal dialogs #686

Open sourcebox opened 3 years ago

sourcebox commented 3 years ago

I had a look into the various areas of the demo and could not find anything. Is it already possible to use modal dialogs, e.g. for errors, user confirmation or an "about box" with credits?

Muqito commented 3 years ago

There's nothing really special about modals.

Just boxes drawn on top of other elements that has focus.

See the demo app:

https://emilk.github.io/egui/index.html

So you can draw the modal if a certain condition is met.

Then you can add buttons to it that closes the modal or triggers a HTTP request and then closes the modal or requests additional information from the user for example.

modals

sourcebox commented 2 years ago

Hmm... The settings window in the demo is not modal, it loses focus when you click another window.

emilk commented 2 years ago

There is no modal windows in egui at the moment, but I suspect adding support for it would be pretty easy (just ignore interactions with the non-modal Area).

I wonder if one should also darken the background when showing a modal window?

sourcebox commented 2 years ago

I wonder if one should also darken the background when showing a modal window?

Something like that would be nice, so the user can easily recognize that his attention is required.

Dinopaterno22 commented 2 years ago

Definitely something that I'd be interested in having, as my current "project" would need to implement a sort of dialog boxes for data introduction! Thanks for hearing @sourcebox out, @emilk :)

plasticartsshow commented 2 years ago

I would like to open a PR that might solve this. Can I?