struct
Event
pub struct Event {
pub kind: String,
pub value: Option<String>,
pub key: Option<String>,
pub x: f32,
pub y: f32,
pub dom: BTreeMap<String, Value>,
pub index: Option<usize>,
pub item: Option<Value>,
pub args: Vec<Value>,
}A UI event. Hosts fill in what they know; handlers bound inside a for loop also receive the loop index and item.
Fields
dom
pub dom: BTreeMap<String, Value>The browser event's own plain values, by their DOM names (deltaX, clientX, shiftKey, pointerType…): every number, text and true/false it has, as MDN documents them. Empty off the browser. Weft's own fields win where a name is the same (x, y, key).
args
pub args: Vec<Value>What a handler call passed (@click: remove(t.id)), for the handler's parameters.
Methods
with_value
pub fn with_value(self, value: impl Into<String>) -> EventThe event with value set: a control's value, or what a component emits.
with_dom
pub fn with_dom(self, dom: BTreeMap<String, Value>) -> EventThe event with the browser event's plain values (see [Event::dom]).
with_args
pub fn with_args(self, args: Vec<Value>) -> EventThe event with args: the values a handler's call passed (@click: remove(t.id)), for its parameters.
to_value
pub fn to_value(&self) -> ValueThe event as a record, as handlers declared in templates see it (event.value, event.index, …).
with_item
pub fn with_item(self, index: usize, item: Value) -> EventThe event as it comes from inside a for loop: the item at index.