Module rg3d_ui::message[][src]

Expand description

Message and events module contains all possible widget messages and OS events.

This UI library uses message passing mechanism to communicate with widgets. This is very simple and reliable mechanism that effectively decouples widgets from each other. There is no direct way of modify something during runtime, you have to use messages to change state of ui elements.

Direction

Each message marked with “Direction” field, which means supported routes for message. For example ButtonMessage::Click has “Direction: To/From UI” which means that it can be sent either from internals of library or from user code. However WidgetMessage::GotFocus has “Direction: From UI” which means that only internal library code can send such messages without a risk of breaking anything.

Structs

Message is basic communication element that is used to deliver information to UI nodes or to user code.

Enums

Message direction allows you to distinguish from where message has came from. Often there is a need to find out who created a message to respond properly. Imagine that we have a NumericUpDown input field for a property and we using some data source to feed data into input field. When we change something in the input field by typing, it creates a message with new value. On other hand we often need to put new value in the input field from some code, in this case we again creating a message. But how to understand from which “side” message has came from? Was it filled in by user and we should create a command to change value in the data source, or it was created from syncing code just to pass new value to UI? This problem solved by setting a direction to a message. Also it solves another problem: often we need to respond to a message only if it did some changes. In this case at first we fire a message with ToWidget direction, widget catches it and checks if changes are needed and if so, it “rethrows” message with direction FromWidget. Listeners are “subscribed” to FromWidget messages only and won’t respond to ToWidget messages.

Traits