[][src]Trait druid::AppDelegate

pub trait AppDelegate<T: Data> {
    fn event(
        &mut self,
        ctx: &mut DelegateCtx,
        window_id: WindowId,
        event: Event,
        data: &mut T,
        env: &Env
    ) -> Option<Event> { ... }
fn command(
        &mut self,
        ctx: &mut DelegateCtx,
        target: Target,
        cmd: &Command,
        data: &mut T,
        env: &Env
    ) -> bool { ... }
fn window_added(
        &mut self,
        id: WindowId,
        data: &mut T,
        env: &Env,
        ctx: &mut DelegateCtx
    ) { ... }
fn window_removed(
        &mut self,
        id: WindowId,
        data: &mut T,
        env: &Env,
        ctx: &mut DelegateCtx
    ) { ... } }

A type that provides hooks for handling and modifying top-level events.

The AppDelegate is a trait that is allowed to handle and modify events before they are passed down the widget tree.

It is a natural place for things like window and menu management.

You customize the AppDelegate by implementing its methods on your own type.

Provided methods

fn event(
    &mut self,
    ctx: &mut DelegateCtx,
    window_id: WindowId,
    event: Event,
    data: &mut T,
    env: &Env
) -> Option<Event>

The AppDelegate's event handler. This function receives all non-command events, before they are passed down the tree.

The return value of this function will be passed down the tree. This can be the event that was passed in, a different event, or no event. In all cases, the update() method will be called as usual.

fn command(
    &mut self,
    ctx: &mut DelegateCtx,
    target: Target,
    cmd: &Command,
    data: &mut T,
    env: &Env
) -> bool

The AppDelegates Command handler.

This function is called with each (Target, Command) pair before they are sent down the tree.

If your implementation returns true, the command will be sent down the widget tree. Otherwise it will not.

To do anything fancier than this, you can submit arbitary commands via DelegateCtx::submit_command.

fn window_added(
    &mut self,
    id: WindowId,
    data: &mut T,
    env: &Env,
    ctx: &mut DelegateCtx
)

The handler for window creation events. This function is called after a window has been added, allowing you to customize the window creation behavior of your app.

fn window_removed(
    &mut self,
    id: WindowId,
    data: &mut T,
    env: &Env,
    ctx: &mut DelegateCtx
)

The handler for window deletion events. This function is called after a window has been removed.

Loading content...

Implementors

Loading content...