ailloli_ui_core/event/focus.rs
1//! Runtime focus-change notification delivered to the affected widget.
2
3/// Focus change notification dispatched to widgets when runtime focus changes.
4///
5/// # Examples
6///
7/// ```
8/// use ailloli_ui_core::event::FocusEvent;
9/// assert!(FocusEvent::new(true).focused);
10/// ```
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub struct FocusEvent {
13 /// `true` when focus was gained and `false` when it was lost.
14 pub focused: bool,
15}
16
17impl FocusEvent {
18 /// Creates a focus-gained (`true`) or focus-lost (`false`) notification.
19 ///
20 /// # Examples
21 ///
22 /// ```
23 /// use ailloli_ui_core::event::FocusEvent;
24 /// assert_eq!(FocusEvent::new(false), FocusEvent { focused: false });
25 /// ```
26 pub fn new(focused: bool) -> Self {
27 Self { focused }
28 }
29}