slint/sixtyfps_runtime/corelib/input.rs
Olivier Goffart caca0d0ba4 Put the component in a Pin<>
Removed the drop and create from the ComponentVTable:
since we are not using VBox<ComponentVTable>, this simplifies a bit
the code of the interpreter and everything else.

But there is still a lot of changes everywhere to support that the Component
is pinned.
This is just for the component. Which would be required if later we want
to access the properties as Pin<Property<_>>. But we have not yet ability
to do projections
2020-06-24 14:13:27 +02:00

29 lines
748 B
Rust

/*! Module handling mouse events
TODO: Keyboard events
*/
use crate::abi::datastructures::MouseEvent;
use crate::ComponentRefPin;
use euclid::default::Vector2D;
pub fn process_mouse_event(component: ComponentRefPin, event: MouseEvent) {
let offset = Vector2D::new(0., 0.);
crate::item_tree::visit_items(
component,
|context, item, offset| {
let geom = item.geometry(context);
let geom = geom.translate(*offset);
if geom.contains(event.pos) {
let mut event2 = event.clone();
event2.pos -= geom.origin.to_vector();
item.input_event(event2, context);
}
geom.origin.to_vector()
},
offset,
);
}