pub struct Event {
pub code: EventKind,
pub key: Option<Key>,
pub pointer: Option<[i32; 4]>,
/* private fields */
}Expand description
An event a window queued for one of its objects.
The target may have been deleted, by safe code too, between the moment the
window queued the event and the moment it is read. The target is therefore
private: Event::is_target compares addresses, and
Event::find_target_in gives a pointer only once it has found the target
in a live object tree.
fn target(event: &graphics::Event) -> *mut graphics::lvgl::lv_obj_t {
event.target
}Fields§
§code: EventKind§key: Option<Key>§pointer: Option<[i32; 4]>Pointer position relative to the target content, plus content width/height, captured at event time rather than when a consumer drains the queue.
Implementations§
Source§impl Event
impl Event
Sourcepub fn is_target(&self, candidate: *const lv_obj_t) -> bool
pub fn is_target(&self, candidate: *const lv_obj_t) -> bool
Compare the queued address with a candidate widget. The event carries no lifetime guarantee, and LVGL may reuse an address after deletion. A window clears the targets of events aimed at its descendants as soon as LVGL reports their deletion, so a queued event never matches a widget created later at the same address; the event itself is kept, with no target, and a cleared target matches nothing, not even a null candidate.
Sourcepub unsafe fn find_target_in(
&self,
root: *mut lv_obj_t,
) -> Option<NonNull<lv_obj_t>>
pub unsafe fn find_target_in( &self, root: *mut lv_obj_t, ) -> Option<NonNull<lv_obj_t>>
The target, if it is root or one of its descendants.
Walks root’s live subtree and compares addresses, so a deleted target
is never dereferenced, and the object returned is live while the
graphics lock stays held. Unlike the window’s own clearing (see
Event::is_target), this holds whatever ran between the deletion
and the read.
§Safety
root must be a live LVGL object, and the caller must hold the
graphics lock.