pub enum CursorEventContent {
Pressed(PressKeyEventType),
Released(PressKeyEventType),
Scroll(ScrollEventConent),
}
Expand description
Enumeration of all possible cursor event types.
CursorEventContent
represents the different kinds of interactions
that can occur with cursor or touch input, including button presses,
releases, and scroll actions.
§Example
use tessera_ui::cursor::{CursorEventContent, PressKeyEventType, ScrollEventConent};
// Handle different event types
match event_content {
CursorEventContent::Pressed(PressKeyEventType::Left) => {
println!("Left button pressed");
}
CursorEventContent::Released(PressKeyEventType::Right) => {
println!("Right button released");
}
CursorEventContent::Scroll(scroll) => {
println!("Scrolled by ({}, {})", scroll.delta_x, scroll.delta_y);
}
}
Variants§
Pressed(PressKeyEventType)
A cursor button or touch point was pressed.
Released(PressKeyEventType)
A cursor button or touch point was released.
Scroll(ScrollEventConent)
A scroll action occurred (mouse wheel, touch drag, or inertial scroll).
Implementations§
Source§impl CursorEventContent
impl CursorEventContent
Sourcepub fn from_press_event(
state: ElementState,
button: MouseButton,
) -> Option<Self>
pub fn from_press_event( state: ElementState, button: MouseButton, ) -> Option<Self>
Creates a cursor press/release event from winit mouse button events.
This method converts winit’s mouse button events into Tessera’s cursor event format. It handles the three standard mouse buttons (left, right, middle) and ignores any additional buttons that may be present on some mice.
§Arguments
state
- Whether the button was pressed or releasedbutton
- Which mouse button was affected
§Returns
Some(CursorEventContent)
for supported mouse buttonsNone
for unsupported mouse buttons
§Example
use tessera_ui::cursor::CursorEventContent;
use winit::event::{ElementState, MouseButton};
let press_event = CursorEventContent::from_press_event(
ElementState::Pressed,
MouseButton::Left
);
if let Some(event) = press_event {
println!("Created cursor event: {:?}", event);
}
Sourcepub fn from_scroll_event(delta: MouseScrollDelta) -> Self
pub fn from_scroll_event(delta: MouseScrollDelta) -> Self
Creates a scroll event from winit mouse wheel events.
This method converts winit’s mouse scroll delta into Tessera’s scroll event format. It handles both line-based scrolling (typical mouse wheels) and pixel-based scrolling (trackpads, precision mice) by applying appropriate scaling.
§Arguments
delta
- The scroll delta from winit
§Returns
A CursorEventContent::Scroll
event with scaled delta values.
§Example
use tessera_ui::cursor::CursorEventContent;
use winit::event::MouseScrollDelta;
let scroll_event = CursorEventContent::from_scroll_event(
MouseScrollDelta::LineDelta(0.0, 1.0) // Scroll down one line
);
match scroll_event {
CursorEventContent::Scroll(scroll) => {
println!("Scroll delta: ({}, {})", scroll.delta_x, scroll.delta_y);
}
_ => {}
}
Trait Implementations§
Source§impl Clone for CursorEventContent
impl Clone for CursorEventContent
Source§fn clone(&self) -> CursorEventContent
fn clone(&self) -> CursorEventContent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CursorEventContent
impl Debug for CursorEventContent
Source§impl PartialEq for CursorEventContent
impl PartialEq for CursorEventContent
impl StructuralPartialEq for CursorEventContent
Auto Trait Implementations§
impl Freeze for CursorEventContent
impl RefUnwindSafe for CursorEventContent
impl Send for CursorEventContent
impl Sync for CursorEventContent
impl Unpin for CursorEventContent
impl UnwindSafe for CursorEventContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more