FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.48k stars 339 forks source link

PopupMessage::Event system for copying events from Popups to their owners. #634

Closed b-guild closed 2 months ago

b-guild commented 2 months ago

I have created another way to allow a widget to handle the events of popups that it opens by having the Popup widget clone the events of its children into a PopupMessage::Event(UiMessage) message.

I modified the context menu code so that when a context menu is opened, the owner of that popup is automatically set to be the widget that was under the right-click. Particularly, the widget being clicked on is the owner, not the widget that has the context menu, because sometimes the particular child that was under the mouse at time may be important information that should not be forgotten, and regardless the events will still bubble up to the widget that has the context menu.

I fixed the issue that was causing context menus to panic when they close. This was an unrelated issue, but fixing it was necessary for testing the PopupMessage::Event messages.

I added a custom Debug implementation for UiMessage, because debugging this commit required me to read many screens of UiMessage debug information and making it more compact was extremely helpful in this.