Skip to main content

EventPayload

Enum EventPayload 

Source
pub enum EventPayload {
Show 30 variants None, Value(PayloadValue), Map(Vec<(&'static str, PayloadValue)>), Layout(Bounds<Points>), Pan { origin: Point<Points>, translation: Point<Points>, velocity_x: f32, velocity_y: f32, value_x: Option<Points>, value_y: Option<Points>, }, PanCancelled { origin: Point<Points>, translation: Point<Points>, velocity_x: f32, velocity_y: f32, value_x: Option<Points>, value_y: Option<Points>, }, Scroll(Point<Points>), Image(Size<DevicePixels>), Error { message: String, }, Text { text: String, count: u32, }, Touch(Box<TouchEvent>), Mouse(MouseEvent), ContextMenu(ContextMenuEvent), Wheel(WheelEvent), Pinch(PinchEvent), Key(KeyEvent), Press(PressEvent), FileDrop(Vec<String>), FileDropAt { uris: Vec<String>, page_position: Point<Points>, }, FileContents(Box<FileContents>), Paste(Box<PasteEvent>), TextDrop(Box<TextDrop>), TextLayout(Vec<TextLine>), Picked { id: u32, files: Vec<PickedFile>, }, Audio { id: u32, event: AudioEvent, }, Window(Box<WindowEvent>), FileRequest { id: u32, paths: Vec<PathBuf>, error: Option<String>, }, CanvasImage { id: u32, result: Result<Vec<u8>, RenderFailure>, }, Native { name: Arc<str>, data: JsonValue, }, Json(JsonValue),
}
Expand description

Data delivered with an event.

Variants§

§

None

No data.

§

Value(PayloadValue)

A single value handed to the handler as is (onValueChange(value)).

§

Map(Vec<(&'static str, PayloadValue)>)

An object with named fields.

§

Layout(Bounds<Points>)

A frame relative to the parent (onLayout).

§

Pan

A drag: translation since the start and velocity (points / second).

Fields

§origin: Point<Points>

Where the finger went down, in the surface.

§translation: Point<Points>

The translation.

§velocity_x: f32

Horizontal velocity.

§velocity_y: f32

Vertical velocity.

§value_x: Option<Points>

The pan.x value now (None without one).

§value_y: Option<Points>

The pan.y value now.

§

PanCancelled

A system-cancelled drag, with the same last values as Pan.

Fields

§origin: Point<Points>

Where the finger went down, in the surface.

§translation: Point<Points>

The translation.

§velocity_x: f32

Horizontal velocity.

§velocity_y: f32

Vertical velocity.

§value_x: Option<Points>

The pan.x value now (None without one).

§value_y: Option<Points>

The pan.y value now.

§

Scroll(Point<Points>)

A scroll position: the content offset.

§

Image(Size<DevicePixels>)

A loaded image’s source size in pixels (before downsampling).

§

Error

An error message.

Fields

§message: String

The message.

§

Text

The text of an input after an edit.

Fields

§text: String

The whole text.

§count: u32

Number of edits the input has reported so far. A value set by JS based on an older edit is stale and must not overwrite newer typing.

§

Touch(Box<TouchEvent>)

Touches (onTouch).

§

Mouse(MouseEvent)

The mouse over a view (onMouseEnter, onMouseMove, onMouseLeave) or a button released over it (onMouseUp, its button naming the released one).

§

ContextMenu(ContextMenuEvent)

A context menu asked for over a view (onContextMenu).

§

Wheel(WheelEvent)

A wheel over a view (onWheel).

§

Pinch(PinchEvent)

A touchpad pinch over a view (onPinch).

§

Key(KeyEvent)

A hardware key transition on a focused Rust view.

§

Press(PressEvent)

Where the pointer was at a press (onPress, onLongPress, onPressDown, onPressUp), with the modifier keys and the click count, on backends that know it.

§

FileDrop(Vec<String>)

Local file URLs offered on drag entry or dropped by the user, in the platform’s order.

§

FileDropAt

Self::FileDrop with where the files were let go, in the window’s coordinates, from backends that know it.

Fields

§uris: Vec<String>

The files’ URLs, as Self::FileDrop’s.

§page_position: Point<Points>

The drop point in the window’s coordinates.

§

FileContents(Box<FileContents>)

Files a drag offers or drops where the platform hands over their contents rather than local paths (the Web): files in the drag’s order, unread on drag entry (types only), and where they were let go. Boxed, as Self::Paste, to keep every payload small.

§

Paste(Box<PasteEvent>)

What the user pasted into an input.

§

TextDrop(Box<TextDrop>)

Text dropped on a view (EventKind::TextDrop); boxed, as Self::Paste, to keep every payload small.

§

TextLayout(Vec<TextLine>)

The lines of a text block.

§

Picked

The files the user picked (EventKind::Pick), with their bytes.

Fields

§files: Vec<PickedFile>

The files, in the order picked; none when cancelled.

§

Audio

What a sound or a player reported (EventKind::Audio, crate::audio).

Fields

§id: u32

The sound or player (crate::audio::AudioCommand::id).

§event: AudioEvent

What it reported.

§

Window(Box<WindowEvent>)

What a window of the app’s own reported (EventKind::Window).

§

FileRequest

Fields

§id: u32

The request.

§paths: Vec<PathBuf>

The paths picked, the path chosen to save to or where a trashed item went; none when cancelled, failed or not known.

§error: Option<String>

Why the request failed; None when it was carried out (or the dialog cancelled).

§

CanvasImage

The image a Command::RenderCanvas made, or why it failed (crate::canvas::render).

Fields

§id: u32

The request.

§result: Result<Vec<u8>, RenderFailure>

The encoded image, or why there is none.

§

Native

An event of a registered native component: its name and data (any JSON value), handed to JS as { name, data }.

Fields

§name: Arc<str>

The event (regionChange).

§data: JsonValue

Its data.

§

Json(JsonValue)

A JSON value handed to JS as it is (EventKind::Host).

Implementations§

Source§

impl EventPayload

Source

pub fn file_answer(id: u32, paths: Vec<PathBuf>) -> EventPayload

The answer to file request id that succeeded with paths: those picked, the one chosen to save to, where a trashed item went, or none (cancelled, or nothing to say).

Source

pub fn file_failed(id: u32, error: impl Into<String>) -> EventPayload

The answer to file request id that failed, with why.

Source§

impl EventPayload

Source

pub fn into_paste(self) -> EventPayload

An onPaste payload of fields (text; a reported paste with no payload is an empty one) made a EventPayload::Paste, as handlers read it (files and uris always there).

Source§

impl EventPayload

Source

pub fn caret(bounds: Bounds<Points>) -> EventPayload

An input’s onCaretMove: the caret’s bounds in the input’s coordinates (its border box, the input’s own scrolling applied), as the platforms report it. The core adds pageBounds (crate::Core::locate_caret).

Trait Implementations§

Source§

impl Clone for EventPayload

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventPayload

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for EventPayload

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EventPayload

Auto Trait Implementations§

§

impl !RefUnwindSafe for EventPayload

§

impl !UnwindSafe for EventPayload

§

impl Forget for EventPayload

§

impl Freeze for EventPayload

§

impl Move for EventPayload

§

impl Send for EventPayload
where RawVecInner: Send, &'static str: Send, BoxRaw<TouchEvent>: Send, Arc<str>: Send, BoxRaw<FileContents>: Send, BoxRaw<PasteEvent>: Send, BoxRaw<TextDrop>: Send, Arc<dyn AsRef<[u8]> + Sync + Send>: Send, Arc<Rgba>: Send, BoxRaw<WindowEvent>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl Sync for EventPayload
where RawVecInner: Sync, BoxRaw<TouchEvent>: Sync, Arc<str>: Sync, BoxRaw<FileContents>: Sync, BoxRaw<PasteEvent>: Sync, BoxRaw<TextDrop>: Sync, Arc<dyn AsRef<[u8]> + Sync + Send>: Sync, Arc<Rgba>: Sync, BoxRaw<WindowEvent>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl Unpin for EventPayload
where *const u8 is !null: Unpin, &'static str: Unpin, Box<TouchEvent>: Unpin, Arc<str>: Unpin, Box<FileContents>: Unpin, Box<PasteEvent>: Unpin, Box<TextDrop>: Unpin, Arc<dyn AsRef<[u8]> + Sync + Send>: Unpin, Arc<Rgba>: Unpin, Box<WindowEvent>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for EventPayload

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.