pub enum Command {
Show 66 variants
Focus,
Blur,
ClearSelection,
SelectAll,
ScrollTo {
x: Points,
y: Points,
animated: bool,
},
LayoutAnimation(LayoutAnimation),
ExitApp,
SetAppUrl(String),
PushAppUrl(String),
Back,
Reload,
GoBack,
GoForward,
StopLoading,
InjectJavaScript(String),
Evaluate {
request: u32,
script: String,
},
CancelEvaluate {
request: u32,
},
PostMessage(String),
SendInput(WebInput),
Load(WebLoad),
Seek(f64),
ScrollToIndex {
index: u32,
animated: bool,
view_position: Percentage,
view_offset: Points,
},
ZoomTo {
scale: f32,
center: Option<Point<Points>>,
animated: bool,
},
Reveal(RevealOptions),
ScrollToEnd {
animated: bool,
},
StatusBar(StatusBarConfig),
Tokens(Arc<Tokens>),
TextLocale(Locale),
SetStatusBar(StatusBarSetting),
Dialog(Box<AlertDialogRequest>),
CloseDialog(u32),
SetJsResponder {
block: bool,
},
ClearJsResponder,
SetSelection {
start: u32,
end: u32,
},
InsertText(String),
Announce(String),
PerfMonitor(bool),
PerfMonitorMode(FpsMode),
ImageInfo {
id: u32,
uri: String,
},
AccessibilityFocus,
Measure {
call: u32,
},
MeasureScrollPosition {
call: u32,
},
SetClipboard(String),
SetClipboardItem(ClipboardItem),
ReadClipboard {
id: u32,
has_only: bool,
},
SetClipboardImage(String),
ReadClipboardImage {
id: u32,
has_only: bool,
},
ReadClipboardFiles {
id: u32,
},
PickImages {
id: u32,
request: PickRequest,
},
PickFiles {
id: u32,
request: FilePickRequest,
},
OpenUrl {
id: u32,
url: String,
},
OpenAppSettings {
id: u32,
},
PickScreenColor {
id: u32,
},
RenderCanvas {
id: u32,
drawing: Arc<Drawing>,
width: u32,
height: u32,
scale: f32,
format: ImageFormat,
},
FileRequest {
id: u32,
request: Box<FileRequest>,
},
Audio(AudioCommand),
Notification(NotificationCommand),
Haptic(Haptic),
Orientations(u8),
Desktop(Box<DesktopCommand>),
HostCall {
id: u64,
name: String,
args: JsonValue,
},
HostPost {
name: String,
args: JsonValue,
},
Native {
name: Arc<str>,
args: JsonValue,
},
OpenEditMenu {
bounds: Bounds<Points>,
actions: Vec<EditAction>,
},
CloseEditMenu,
WebViewRequest(WebViewRequest),
// some variants omitted
}Expand description
An imperative call on a native view (ref.focus() and the like).
Variants§
Focus
Focus an input (show the keyboard).
Blur
Unfocus an input; on the root view, unfocus whatever is focused.
ClearSelection
Clear the selection of a selectable view (ViewProps::selectable_view)
the view is, is inside or holds.
SelectAll
Select all the text of the selectable view (ViewProps::selectable_view)
the view is or is inside, as the selection menu’s Select All does.
ScrollTo
Scroll a scroll view to an offset.
LayoutAnimation(LayoutAnimation)
Animate the layout changes of the next commit. On the root, all of
them; on a node, with its update, only the frames that node’s
change moves (ElementRef::animate_layout, core/layout_scope.rs).
ExitApp
Leave the app (Android back handling; on the root).
SetAppUrl(String)
The app’s address (UrlScheme.setUrl, set_app_url; on the root):
the web replaces the current history entry’s; iOS and macOS give it
to the system when the app opts in (Handoff); the other
platforms keep none (crate::url_scheme).
PushAppUrl(String)
The app’s address as an entry of its own after the current one
(UrlScheme.setUrl(url, { history: "push" }), set_app_url_with; on
the root): the web pushes one unless the same turn pushed a page’s
or it is the address shown; iOS and macOS take it as
Command::SetAppUrl; the other platforms keep none.
Back
What the back button does when none of the app’s listeners took
it: the innermost stack pops (or asks, with popOnBack false); with
none, the app leaves on Android (on the root).
Reload
Reload a web view.
GoBack
Go back in a web view’s history.
GoForward
Go forward in a web view’s history.
StopLoading
Stop loading a web view.
InjectJavaScript(String)
Run JavaScript in a web view’s page.
Evaluate
Run a script in a web view’s page for its result
(crate::platform::web_evaluation); the platform answers on this
node with EventKind::WebEvaluation (id: the request, data:
the JSON envelope), once.
CancelEvaluate
Give up request request of Command::Evaluate: release what the
platform keeps for it, answering nothing.
PostMessage(String)
Send a message to a web view’s page (window.onmessage data).
SendInput(WebInput)
Give a web view’s page input as the user’s own (trusted events).
Load(WebLoad)
Load a page in a web view with headers on its request.
Seek(f64)
Seek a video to a time in seconds.
ScrollToIndex
Scroll a list to an item (resolved by the core into ScrollTo).
Fields
view_position: PercentageWhere the item ends up: 0 at the start of the viewport, 1 at the end, 0.5 in the middle.
ZoomTo
Zoom a zoomable scroll view to scale, with the content point
(x, y) (points, unzoomed) in the middle of the viewport, or
around the viewport’s middle.
Fields
Reveal(RevealOptions)
Scroll the scroll views around the view so it shows (resolved by
the core into their ScrollTo; never mounted).
ScrollToEnd
Scroll a list to the end of its content.
StatusBar(StatusBarConfig)
Set the status bar (on the root): what the platform shows.
Tokens(Arc<Tokens>)
The design tokens the app is drawn with (on the root), sent when
they change (crate::Core::tokens): what the platform’s own
controls (Linux’s menus, Android’s and iOS’s alerts and action
sheets) take their colors from, by the tokens’ names (popover,
accent, border, …).
TextLocale(Locale)
The language the app’s text shows in (crate::i18n: its selected
language, setLocale’s or the embedding app’s included), on the
root of an iOS or Android surface, sent when it changes: the words
the platform speaks for states it has no system words for
(checked, expanded, invalid…) follow it.
SetStatusBar(StatusBarSetting)
Change what functions set for the status bar (on the root): the
core merges it under the settings components render and sends
Command::StatusBar when the result changes.
Dialog(Box<AlertDialogRequest>)
Show an alert or action sheet (on the root); the answer comes back
as EventKind::Dialog.
CloseDialog(u32)
Close the dialog Command::Dialog showed with this id (on the
root), as if dismissed, without reporting an answer: the app no
longer wants one, and the core has already answered it.
SetJsResponder
A JS responder took the touches on this view: block keeps native
scroll views around it from taking them over.
ClearJsResponder
The JS responder let go (on the root).
SetSelection
Select a range of an input (UTF-16 units; equal for a caret).
Platforms drop it when the same batch brought the input a value
they dropped as stale (MountItem::InputValue’s count): its
offsets are for the text JS had, not for what the user typed since.
InsertText(String)
Insert text into an input in place of its selection, as the user’s
edit: the input’s maxLength and line rules apply, onChangeText
reports it, no key is reported, and where the platform keeps an
undo history it is a step of it (unlike a new value). With
pasteBehavior "report", the app inserts a paste it allowed or
rewrote this way.
Announce(String)
Have the screen reader read a message (on the root).
PerfMonitor(bool)
Turn the performance monitor on or off (on the root;
setFpsEnabled): what the platform has of one, the
macOS panel or the other platforms’ nsh::fps lines. Platforms
without a monitor ignore it.
PerfMonitorMode(FpsMode)
How the performance monitor shows (on the root; setFpsMode): its
whole panel, collapsed to its frame rate, or nothing while it still
measures. Platforms without a panel ignore it.
ImageInfo
Load the image at uri (keeping its bytes for views that show it
next) and report its pixel size as EventKind::ImageInfo id
(on the root).
AccessibilityFocus
Move the screen reader’s focus to this view.
Measure
Measure the view with this commit’s layout (ref.measure()):
answered by the core in its events for promise call
(crate::element::JsEvent::Reply: a crate::Measurement, or null
when the view is not laid out); never mounted.
MeasureScrollPosition
Where a list’s viewport starts among its rows, with this commit’s
layout (ref.measureScrollPosition()): answered by the core in its
events for promise call (a crate::ListScrollPosition, or null
for a view that is no list or a list without items); never
mounted.
SetClipboard(String)
Put text on the system clipboard (on the root; Clipboard.writeText).
SetClipboardItem(ClipboardItem)
Put one item on the system clipboard, each of its formats in one
write: the text as plain text, the HTML (when it has some) as the
platform’s HTML type, which apps that read formatting paste (on the
root; Clipboard.write). A platform without an HTML type puts the
text only. New formats of crate::element::ClipboardItem come in
the same command.
ReadClipboard
Read the system clipboard and report it as EventKind::Clipboard
id (on the root): has and, unless has_only, text. Asking
only whether it holds text does not read it (no iOS paste notice).
SetClipboardImage(String)
Put the image of a data: URI on the system clipboard, replacing
what it holds (on the root; Clipboard.writeImage).
ReadClipboardImage
Read the image on the system clipboard and report it as
EventKind::Clipboard id (on the root): has and, unless
has_only, the image as a data: URI (uri) and its size in
pixels (width, height), or for an image over
crate::platform::clipboard::MAX_IMAGE_BYTES its size in bytes
(tooLarge; crate::platform::clipboard::image_answer).
ReadClipboardFiles
Read the local files on the system clipboard (files copied in a
file manager) and report them as EventKind::Clipboard id (on
the root): has and files, their file: URLs one per line.
PickImages
Show the system’s picker for images (on the root;
Picker.pickImages), prepare the picked ones as request says
(crate::picker) and report them as EventKind::Pick
(EventPayload::Picked id; no files when cancelled).
PickFiles
Show the system’s picker for files of any type (on the root;
Picker.pickFiles) and report the picked ones, their bytes as they
are, as EventKind::Pick (EventPayload::Picked id; no files
when cancelled; crate::picker).
OpenUrl
Open url outside the app (on the root; openUrl of nsh/device,
crate::open_url): the browser, the mail or phone app, the app
that registered its scheme. Report whether it opened as
EventKind::OpenUrl id. The core sends it once the URL was
checked and the embedding app did not take it.
OpenAppSettings
Open the app’s own page in the system’s settings (on the root;
nsh/mobile’s AppSettings.open,
crate::mobile::open_app_settings): iOS’s
UIApplication.openSettingsURLString, Android’s application
details. Report whether the system opened it as
EventKind::OpenAppSettings id. Sent only on platforms whose
crate::platform::Environment::app_settings is set.
PickScreenColor
Let the user pick a color anywhere on the screen (on the root; a
color picker’s eyedropper, [crate::element::ambient::pick_screen_color]):
the system’s color sampler or the browser’s EyeDropper. Report it
as EventKind::ScreenColor id, with no color when the user
cancelled. Sent only on platforms whose
crate::platform::Environment::screen_color is set.
RenderCanvas
Render drawing offscreen into a width × height pixel image
(on the root; OffscreenCanvas’s convertToBlob,
crate::canvas::render): replay it as a canvas of scale pixels
per point draws it on screen, into a bitmap of its own that starts
transparent, its animated values at 0, and report the encoded image
as EventKind::CanvasImage id (EventPayload::CanvasImage).
Sent only on platforms whose
crate::platform::Environment::canvas_render is set, with a size
[crate::canvas::render::pixel_size] passed.
Fields
format: ImageFormatThe encoding.
FileRequest
Carry out request on local paths (on the root;
crate::file_dialog): show the open or save dialog, open a file
in its app, show it in the file manager or move it to the trash.
Report it as EventKind::FileRequest id
(EventPayload::FileRequest). Sent only on platforms whose
crate::platform::Environment::file_requests is set.
Audio(AudioCommand)
Load, play and free sounds, open and drive players (on the root;
Sound and AudioPlayer of nsh, crate::audio) and report
what happens as EventKind::Audio (EventPayload::Audio). Sent
only on platforms whose crate::platform::Environment::audio is
set.
Notification(NotificationCommand)
Show a notification, ask for the permission, set the app’s badge
(on the root; Notifications of nsh, crate::notifications).
Haptic(Haptic)
Play a haptic (on the root; Haptics of nsh/mobile,
crate::element::haptic). Platforms without haptics ignore it.
Orientations(u8)
The orientations the screen may take (on the root; the
supportedOrientations of the page shown, ScreenProp::Orientations):
crate::ModalConfig::PORTRAIT bits, 0 for the app’s own. iOS and
Android; the other platforms ignore it.
Desktop(Box<DesktopCommand>)
A desktop command (on the root; nsh/desktop): the window, its
title bar, menus. Mobile platforms ignore it.
HostCall
Call function name of the app embedding NSH (on the root;
nsh/host’s host.call): the platform answers with
EventKind::Host { type: "reply", id, .. }. Sent only on
platforms whose crate::platform::Environment::host is set, for
functions the app’s capabilities.host grants.
Fields
HostPost
Hand args to function name of the app embedding NSH, with no
answer (on the root; nsh/host’s host.post without a native SDK
channel). Sent only on platforms whose
crate::platform::Environment::host is set, for functions the
app’s capabilities.host grants.
Fields
Native
A call on a registered native component (ref.command(name, args)).
OpenEditMenu
Open the system’s edit menu over bounds (in the root view) on an
input that has the focus: the menu of a component that draws its
own text selection (RichEditor’s on touch screens). UIKit’s
UIEditMenuInteraction on iOS, a floating ActionMode on Android;
platforms without such a menu ignore it. It offers actions, in the
platform’s order: Paste pastes into the input as the user’s paste
does (onPaste), the others are reported as
EventKind::EditAction. The menu closes when an action is chosen.
Fields
actions: Vec<EditAction>The actions it offers; those that cannot apply are left out, not disabled.
CloseEditMenu
Close the edit menu Command::OpenEditMenu opened on an input.
WebViewRequest(WebViewRequest)
A request on a web view (crate::webview) sent once the target is
known to be a mounted, granted web view; the platform answers on
this node with EventKind::WebViewReply (id: the request).