/// Construct MouseData with the specified properties
///
/// Note: the current implementation truncates coordinates. In the future, when we change the internal representation, it may also support a fractional part.
Construct MouseData with the specified properties
Note: the current implementation truncates coordinates. In the future, when we change the internal representation, it may also support a fractional part.
Construct MouseData with the specified properties Note : the current implementation truncates coordinates . In the future when we change the internal representation it may also support a fractional part .
pub fn new(
            coordinates: Coordinates,
            trigger_button: Option<MouseButton>,
            held_buttons: MouseButtonSet,
            modifiers: Modifiers,
        ) -> Self {
            let alt_key = modifiers.contains(Modifiers::ALT);
            let ctrl_key = modifiers.contains(Modifiers::CONTROL);
            let meta_key = modifiers.contains(Modifiers::META);
            let shift_key = modifiers.contains(Modifiers::SHIFT);
            let [client_x, client_y]: [i32; 2] = coordinates.client().cast().into();
            let [offset_x, offset_y]: [i32; 2] = coordinates.element().cast().into();
            let [page_x, page_y]: [i32; 2] = coordinates.page().cast().into();
            let [screen_x, screen_y]: [i32; 2] = coordinates.screen().cast().into();
            #[allow(deprecated)]
            Self {
                alt_key,
                ctrl_key,
                meta_key,
                shift_key,
                button: trigger_button.map_or(0, |b| b.into_web_code()),
                buttons: encode_mouse_button_set(held_buttons),
                client_x,
                client_y,
                offset_x,
                offset_y,
                page_x,
                page_y,
                screen_x,
                screen_y,
            }
        }
pub fn new ( coordinates : Coordinates , trigger_button : Option < MouseButton > , held_buttons : MouseButtonSet , modifiers : Modifiers , ) -> Self { let alt_key = modifiers . contains ( Modifiers :: ALT ) ; let ctrl_key = modifiers . contains ( Modifiers :: CONTROL ) ; let meta_key = modifiers . contains ( Modifiers :: META ) ; let shift_key = modifiers . contains ( Modifiers :: SHIFT ) ; let [ client_x , client_y ] : [ i32 ; 2 ] = coordinates . client ( ) . cast ( ) . into ( ) ; let [ offset_x , offset_y ] : [ i32 ; 2 ] = coordinates . element ( ) . cast ( ) . into ( ) ; let [ page_x , page_y ] : [ i32 ; 2 ] = coordinates . page ( ) . cast ( ) . into ( ) ; let [ screen_x , screen_y ] : [ i32 ; 2 ] = coordinates . screen ( ) . cast ( ) . into ( ) ; # [ allow ( deprecated ) ] Self { alt_key , ctrl_key , meta_key , shift_key , button : trigger_button . map_or ( 0 , | b | b . into_web_code ( ) ) , buttons : encode_mouse_button_set ( held_buttons ) , client_x , client_y , offset_x , offset_y , page_x , page_y , screen_x , screen_y , } }
Construct MouseData with the specified properties
Note: the current implementation truncates coordinates.
Construct MouseData with the specified properties Note : the current implementation truncates coordinates .
coordinates
Coordinates
trigger_button
Option<MouseButton>
held_buttons
MouseButtonSet
modifiers
Modifiers