pub trait Cascade {
// Provided methods
fn keystroke(
&mut self,
_field: &FieldRef,
change: Keystroke,
) -> KeystrokeOutcome { ... }
fn keystroke_commit(&mut self, _field: &FieldRef, _value: &str) -> bool { ... }
fn validate(&mut self, _field: &FieldRef, _value: &str) -> bool { ... }
fn calculate(&mut self, _writes: &mut FieldWrites, _trigger: &FieldRef) { ... }
fn format(&mut self, _field: &FieldRef, _value: &str) -> Option<String> { ... }
fn pointer(
&mut self,
_field: &FieldRef,
_trigger: PointerTrigger,
_held: Modifiers,
) { ... }
fn take_focus_request(&mut self) -> Option<u32> { ... }
fn drain_border_style_writes(&mut self) -> Vec<(u32, BorderStyle)> { ... }
}Expand description
The script hooks a commit passes through.
One implementation ships here — NoScripts — and its behaviour is the
method defaults below. See the module documentation for why those are the
specification rather than a placeholder.
Provided Methods§
Sourcefn keystroke(
&mut self,
_field: &FieldRef,
change: Keystroke,
) -> KeystrokeOutcome
fn keystroke( &mut self, _field: &FieldRef, change: Keystroke, ) -> KeystrokeOutcome
The keystroke hook, with no commit imminent: may rewrite or reject what is being typed.
Sourcefn keystroke_commit(&mut self, _field: &FieldRef, _value: &str) -> bool
fn keystroke_commit(&mut self, _field: &FieldRef, _value: &str) -> bool
The keystroke hook with a commit imminent: may reject the commit.
Sourcefn validate(&mut self, _field: &FieldRef, _value: &str) -> bool
fn validate(&mut self, _field: &FieldRef, _value: &str) -> bool
The validation hook: may reject the commit.
Sourcefn calculate(&mut self, _writes: &mut FieldWrites, _trigger: &FieldRef)
fn calculate(&mut self, _writes: &mut FieldWrites, _trigger: &FieldRef)
The calculation hook: may rewrite other fields’ values.
Sourcefn format(&mut self, _field: &FieldRef, _value: &str) -> Option<String>
fn format(&mut self, _field: &FieldRef, _value: &str) -> Option<String>
The format hook: may return a display string that does not change the stored value.
None means “display the raw value”, which is exactly what a build
without scripts does — and exactly why such a build shows 1234 where
a formatting script would show a currency amount.
Sourcefn pointer(
&mut self,
_field: &FieldRef,
_trigger: PointerTrigger,
_held: Modifiers,
)
fn pointer( &mut self, _field: &FieldRef, _trigger: PointerTrigger, _held: Modifiers, )
A pointer or focus event reached a field.
This hook changes nothing and cannot refuse anything, which is why
it returns () where the four above return an answer: the six /AA
entries it covers can talk to the host and read the form, and
event.value is not even live for them. A viewer runs them for their
side effects and carries on regardless.
It is one method over six triggers rather than six methods because
nothing downstream branches on which one fired — the branch is inside
the implementation, on the event object it populates.
Sourcefn take_focus_request(&mut self) -> Option<u32>
fn take_focus_request(&mut self) -> Option<u32>
The field a script asked the keyboard for, drained.
A position in the document-wide field list — the space
FieldRef::index counts in — or None when nothing asked.
Recorded while a script runs and spent afterwards. Moving the
keyboard from inside a running script would re-enter the routing the
script is already inside, so the request is written down here and the
caller routes it through the same path a click takes: the outgoing
field’s /AA /Bl, then the incoming field’s /AA /Fo.
The default is None — NoScripts’s answer and every
non-scripting cascade’s, because with no engine nothing can ask.
Sourcefn drain_border_style_writes(&mut self) -> Vec<(u32, BorderStyle)>
fn drain_border_style_writes(&mut self) -> Vec<(u32, BorderStyle)>
Field.borderStyle writes a script made, drained.
Each entry is a /Fields position and the style the setter accepted.
Spent after the script returns so the appearance regenerates through
the ordinary path rather than from inside a native function.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".