pub struct UiMessage {
pub handled: Cell<bool>,
pub data: Rc<dyn MessageData>,
pub destination: Handle<UiNode>,
pub direction: MessageDirection,
pub perform_layout: Cell<bool>,
pub flags: u64,
}
Expand description
Message is basic communication element that is used to deliver information to UI nodes or to user code.
Threading
UiMessage is nor Send or Sync. User interface is a single-thread thing, as well as its messages.
Fields§
§handled: Cell<bool>
Useful flag to check if a message was already handled.
data: Rc<dyn MessageData>
Actual message data.
destination: Handle<UiNode>
Handle of node that will receive message. Please note that all nodes in hierarchy will also receive this message, order is “up-on-tree”.
direction: MessageDirection
Indicates the direction of the message.
See MessageDirection for details.
perform_layout: Cell<bool>
Whether or not message requires layout to be calculated first.
Some of message handling routines uses layout info, but message loop performed right after layout pass, but some of messages may change layout and this flag tells UI to perform layout before passing message further. In ideal case we’d perform layout after each message, but since layout pass is super heavy we should do it only when it is actually needed.
flags: u64
A custom user flags.
Implementations§
source§impl UiMessage
impl UiMessage
pub fn with_data<T: MessageData>(data: T) -> Self
pub fn with_destination(self, destination: Handle<UiNode>) -> Self
pub fn with_direction(self, direction: MessageDirection) -> Self
pub fn with_handled(self, handled: bool) -> Self
pub fn with_perform_layout(self, perform_layout: bool) -> Self
sourcepub fn reverse(&self) -> Self
pub fn reverse(&self) -> Self
Creates a new copy of the message with reversed direction. Typical use case is to re-send messages to create “response” in widget. For example you have a float input field and it has Value message. When the input field receives Value message with MessageDirection::ToWidget it checks if value needs to be changed and if it does, it re-sends same message but with reversed direction back to message queue so every “listener” can reach properly. The input field won’t react at MessageDirection::FromWidget message so there will be no infinite message loop.
pub fn destination(&self) -> Handle<UiNode>
pub fn data<T: MessageData>(&self) -> Option<&T>
pub fn set_handled(&self, handled: bool)
pub fn handled(&self) -> bool
pub fn direction(&self) -> MessageDirection
pub fn set_perform_layout(&self, value: bool)
pub fn need_perform_layout(&self) -> bool
pub fn has_flags(&self, flags: u64) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UiMessage
impl !Send for UiMessage
impl !Sync for UiMessage
impl Unpin for UiMessage
impl !UnwindSafe for UiMessage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere T: 'static,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.