[][src]Trait gui::MutCap

pub trait MutCap<E>: Cap where
    E: Debug
{ fn add_widget(
        &mut self,
        parent: Id,
        new_widget: &'f mut dyn FnMut(Id, &mut dyn MutCap<E>) -> Box<dyn Widget<E>>
    ) -> Id;
fn show(&mut self, widget: Id);
fn hide(&mut self, widget: Id);
fn focus(&mut self, widget: Id);
fn hook_events(
        &mut self,
        widget: Id,
        hook_fn: Option<&'static dyn Fn(&mut dyn Widget<E>, &E, &dyn Cap) -> Option<UiEvents<E>>>
    ) -> Option<&'static dyn Fn(&mut dyn Widget<E>, &E, &dyn Cap) -> Option<UiEvents<E>>>; }

A mutable capability allowing for various widget related operations.

Required methods

fn add_widget(
    &mut self,
    parent: Id,
    new_widget: &'f mut dyn FnMut(Id, &mut dyn MutCap<E>) -> Box<dyn Widget<E>>
) -> Id

Add a widget to the Ui represented by the capability.

fn show(&mut self, widget: Id)

Show a widget, i.e., set its and its parents' visibility flag.

This method sets the referenced widget's visibility flag as well as those of all its parents.

fn hide(&mut self, widget: Id)

Hide a widget, i.e., unset its visibility flag.

This method makes sure that widget referenced is no longer displayed. If the widget has children, all those children will also be hidden.

fn focus(&mut self, widget: Id)

Focus a widget.

The focused widget is the one receiving certain types of events (such as key events) first but may also be rendered in a different color or be otherwise highlighted. Note that being focused implies being visible. This invariant is enforced internally.

fn hook_events(
    &mut self,
    widget: Id,
    hook_fn: Option<&'static dyn Fn(&mut dyn Widget<E>, &E, &dyn Cap) -> Option<UiEvents<E>>>
) -> Option<&'static dyn Fn(&mut dyn Widget<E>, &E, &dyn Cap) -> Option<UiEvents<E>>>

Install or remove an event hook handler.

The event hook handler is a call back function that is invoked for all events originating outside of the UI, i.e., those that come in through the Ui::handle method. For such events, the event hook handler gets to inspect the event before any widget gets a chance to handle it "officially" through the Handleable::handle method.

Event hook handlers are allowed to emit events on its own, just as "normal" event handlers. It is guaranteed that these emitted events will reach the widget after the event that was hooked.

Note that event hook functions are only able to inspect events and not change or discard them. That restriction prevents conflicts due to what effectively comes down to shared global state: widgets could be racing to install an event hook handler and the order in which these handlers end up being installed could influence the handling of events.

A widget (identified by the given Id) may only register one handler and subsequent requests will overwrite the previously installed one. The method returns the handler that was previously installed, if any.

Loading content...

Implementors

impl<E> MutCap<E> for Ui<E> where
    E: 'static + Debug
[src]

fn add_widget(
    &mut self,
    parent: Id,
    new_widget: &'f mut dyn FnMut(Id, &mut dyn MutCap<E>) -> Box<dyn Widget<E>>
) -> Id
[src]

Add a widget to the Ui.

fn show(&mut self, widget: Id)[src]

Show a widget, i.e., set its and its parents' visibility flag.

fn hide(&mut self, widget: Id)[src]

Hide a widget, i.e., unset its visibility flag.

fn focus(&mut self, widget: Id)[src]

Focus a widget.

fn hook_events(
    &mut self,
    widget: Id,
    hook_fn: Option<&'static dyn Fn(&mut dyn Widget<E>, &E, &dyn Cap) -> Option<UiEvents<E>>>
) -> Option<&'static dyn Fn(&mut dyn Widget<E>, &E, &dyn Cap) -> Option<UiEvents<E>>>
[src]

Install or remove an event hook handler.

Loading content...