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
PanCancelled
A system-cancelled drag, with the same last values as Pan.
Fields
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.
Text
The text of an input after an edit.
Fields
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.
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
id: u32The request (Command::PickImages, Command::PickFiles).
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: u32The sound or player (crate::audio::AudioCommand::id).
event: AudioEventWhat it reported.
Window(Box<WindowEvent>)
What a window of the app’s own reported (EventKind::Window).
FileRequest
The answer to a Command::FileRequest (EventKind::FileRequest,
crate::file_dialog).
Fields
CanvasImage
The image a Command::RenderCanvas made, or why it failed
(crate::canvas::render).
Fields
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 }.
Json(JsonValue)
A JSON value handed to JS as it is (EventKind::Host).
Implementations§
Source§impl EventPayload
impl EventPayload
Sourcepub fn file_answer(id: u32, paths: Vec<PathBuf>) -> EventPayload
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).
Sourcepub fn file_failed(id: u32, error: impl Into<String>) -> EventPayload
pub fn file_failed(id: u32, error: impl Into<String>) -> EventPayload
The answer to file request id that failed, with why.
Source§impl EventPayload
impl EventPayload
Sourcepub fn into_paste(self) -> EventPayload
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
impl EventPayload
Sourcepub fn caret(bounds: Bounds<Points>) -> EventPayload
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).