[][src]Struct druid::EventCtx

pub struct EventCtx<'a> { /* fields omitted */ }

A mutable context provided to event handling methods of widgets.

Widgets should call request_paint whenever an event causes a change in the widget's appearance, to schedule a repaint.

Methods

impl<'a> EventCtx<'a>[src]

pub fn invalidate(&mut self)[src]

Deprecated since 0.5.0:

use request_paint instead

pub fn request_paint(&mut self)[src]

Request a paint pass.

pub fn request_layout(&mut self)[src]

Request a layout pass.

A Widget's layout method is always called when the widget tree changes, or the window is resized.

If your widget would like to have layout called at any other time, (such as if it would like to change the layout of children in response to some event) it must call this method.

pub fn children_changed(&mut self)[src]

Indicate that your children have changed.

Widgets must call this method after adding a new child.

pub fn text(&mut self) -> Text[src]

Get an object which can create text layouts.

pub fn set_cursor(&mut self, cursor: &Cursor)[src]

Set the cursor icon.

Call this when handling a mouse move event, to set the cursor for the widget. A container widget can safely call this method, then recurse to its children, as a sequence of calls within an event propagation only has the effect of the last one (ie no need to worry about flashing).

This method is expected to be called mostly from the MouseMoved event handler, but can also be called in response to other events, for example pressing a key to change the behavior of a widget.

pub fn set_active(&mut self, active: bool)[src]

Set the "active" state of the widget.

See EventCtx::is_active.

pub fn is_hot(&self) -> bool[src]

The "hot" (aka hover) status of a widget.

A widget is "hot" when the mouse is hovered over it. Widgets will often change their appearance as a visual indication that they will respond to mouse interaction.

The hot status is computed from the widget's layout rect. In a container hierarchy, all widgets with layout rects containing the mouse position have hot status.

Discussion: there is currently some confusion about whether a widget can be considered hot when some other widget is active (for example, when clicking to one widget and dragging to the next). The documentation should clearly state the resolution.

pub fn is_active(&self) -> bool[src]

The active status of a widget.

Active status generally corresponds to a mouse button down. Widgets with behavior similar to a button will call set_active on mouse down and then up.

When a widget is active, it gets mouse events even when the mouse is dragged away.

pub fn window(&self) -> &WindowHandle[src]

Returns a reference to the current WindowHandle.

pub fn set_handled(&mut self)[src]

Set the event as "handled", which stops its propagation to other widgets.

pub fn is_handled(&self) -> bool[src]

Determine whether the event has been handled by some other widget.

pub fn has_focus(&self) -> bool[src]

The focus status of a widget.

Focus means that the widget receives keyboard events.

A widget can request focus using the request_focus method. This will generally result in a separate event propagation of a FocusChanged method, including sending false to the previous widget that held focus.

Only one leaf widget at a time has focus. However, in a container hierarchy, all ancestors of that leaf widget are also invoked with FocusChanged(true).

Discussion question: is "is_focused" a better name?

pub fn is_focused(&self) -> bool[src]

The (leaf) focus status of a widget. See has_focus.

pub fn request_focus(&mut self)[src]

Request keyboard focus.

See has_focus for more information.

pub fn focus_next(&mut self)[src]

Transfer focus to the next focusable widget.

This should only be called by a widget that currently has focus.

pub fn focus_prev(&mut self)[src]

Transfer focus to the previous focusable widget.

This should only be called by a widget that currently has focus.

pub fn resign_focus(&mut self)[src]

Give up focus.

This should only be called by a widget that currently has focus.

pub fn request_anim_frame(&mut self)[src]

Request an animation frame.

pub fn request_timer(&mut self, deadline: Instant) -> TimerToken[src]

Request a timer event.

The return value is a token, which can be used to associate the request with the event.

pub fn size(&self) -> Size[src]

The layout size.

This is the layout size as ultimately determined by the parent container, on the previous layout pass.

Generally it will be the same as the size returned by the child widget's layout method.

pub fn submit_command(
    &mut self,
    command: impl Into<Command>,
    target: impl Into<Option<Target>>
)
[src]

Submit a Command to be run after this event is handled.

Commands are run in the order they are submitted; all commands submitted during the handling of an event are executed before the update method is called.

pub fn window_id(&self) -> WindowId[src]

Get the window id.

pub fn widget_id(&self) -> WidgetId[src]

get the WidgetId of the current widget.

Auto Trait Implementations

impl<'a> !RefUnwindSafe for EventCtx<'a>

impl<'a> !Send for EventCtx<'a>

impl<'a> !Sync for EventCtx<'a>

impl<'a> Unpin for EventCtx<'a>

impl<'a> !UnwindSafe for EventCtx<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.