Skip to main content

MessageBox

Struct MessageBox 

Source
pub struct MessageBox {
    pub style: Style,
    pub text_color: Color,
    pub button_text_color: Color,
    /* private fields */
}
Expand description

LVGL-parity message-box dialog (LPAR-14 §5.H).

Combines a title header, a wrapped body message, and a button row into a single widget. The button row is implemented as an internal ButtonMatrix.

§Button IDs

Buttons are assigned sequential ButtonId values in the order supplied to new. Use those IDs with active_button and [activate_button].

Fields§

§style: Style

Style for the outer container.

§text_color: Color

Text colour for the title and body.

§button_text_color: Color

Text colour for the button labels (forwarded to the inner matrix).

Implementations§

Source§

impl MessageBox

Source

pub fn new(bounds: Rect, title: &str, text: &str, buttons: &[&str]) -> Self

Create a MessageBox with the given bounds, title, body text, and button labels.

buttons is a slice of label strings. An empty slice creates a message-box with no footer buttons.

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this widget (FONT-00 §5); resolves to FONT_6X10 when unset.

Source

pub fn title(&self) -> &str

Return the current title string.

Source

pub fn set_title(&mut self, title: &str)

Replace the title string.

Source

pub fn text(&self) -> &str

Return the current body text.

Source

pub fn set_text(&mut self, text: &str)

Replace the body text.

Source

pub fn active_button(&self) -> ButtonId

Return the most-recently activated button, or BUTTON_NONE if no button has been activated yet.

Source

pub fn activate_button(&mut self, id: ButtonId)

Programmatically activate button id, recording it as the active button. Equivalent to the user pressing a button.

Source

pub fn button_text(&self, id: ButtonId) -> Option<&str>

Return the label of button id, or None if id is out of range.

Source

pub fn button_count(&self) -> usize

Return the total number of buttons in the footer row.

Source

pub fn close(&mut self) -> ButtonId

Signal that the dialog should be dismissed.

Records closed = true and returns the currently active_button. The caller must detach or hide the widget; no z-order or tree manipulation is performed.

Source

pub fn is_closed(&self) -> bool

Return true after close has been called.

Trait Implementations§

Source§

impl Widget for MessageBox

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn set_bounds(&mut self, new_bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.