1+ use  crate :: event:: MouseButton :: Left ; 
2+ 
13/// A key event. 
24#[ derive( Debug ,  Clone ,  Eq ,  PartialEq ) ]  
35pub  struct  KeyEvent  { 
@@ -159,23 +161,6 @@ pub enum MouseEventKind {
159161
160162/// Convert a [`web_sys::MouseEvent`] to a [`MouseEvent`]. 
161163impl  MouseEvent  { 
162-     /// Determines the correct mouse button for the event, handling the JS API behavior 
163-      /// where move events always report button 0 (Left) regardless of actual button state. 
164-      fn  resolve_mouse_button ( event_type :  MouseEventKind ,  raw_button :  i16 )  -> MouseButton  { 
165-         use  MouseButton :: * ; 
166-         match  ( event_type,  raw_button. into ( ) )  { 
167-             ( MouseEventKind :: Moved ,  Left )  => Unidentified , 
168-             ( _,  button)  => button, 
169-         } 
170-     } 
171- 
172-     /// Converts pixel coordinates to grid coordinates. 
173-      fn  pixels_to_grid_coords ( pixel_x :  u32 ,  pixel_y :  u32 ,  cell_size_px :  ( u32 ,  u32 ) )  -> ( u16 ,  u16 )  { 
174-         let  col = ( pixel_x / cell_size_px. 0 )  as  u16 ; 
175-         let  row = ( pixel_y / cell_size_px. 1 )  as  u16 ; 
176-         ( col,  row) 
177-     } 
178- 
179164    /// Creates a new [`MouseEvent`] from a web mouse event and cell size information. 
180165     /// 
181166     /// This uses viewport-relative coordinates. 
@@ -184,9 +169,6 @@ impl MouseEvent {
184169     /// * `event` - The web mouse event from the browser 
185170     /// * `cell_size_px` - The pixel dimensions of a terminal cell (width, height) 
186171     pub  fn  new ( event :  web_sys:: MouseEvent ,  cell_size_px :  ( u32 ,  u32 ) )  -> Self  { 
187-         debug_assert ! ( event. x( )  <= 0xffff ) ; 
188-         debug_assert ! ( event. y( )  <= 0xffff ) ; 
189- 
190172        let  ctrl = event. ctrl_key ( ) ; 
191173        let  alt = event. alt_key ( ) ; 
192174        let  shift = event. shift_key ( ) ; 
@@ -249,6 +231,23 @@ impl MouseEvent {
249231            shift, 
250232        } 
251233    } 
234+ 
235+     /// Determines the correct mouse button for the event, handling the JS API behavior 
236+      /// where move events always report button 0 (Left) regardless of actual button state. 
237+      fn  resolve_mouse_button ( event_type :  MouseEventKind ,  raw_button :  i16 )  -> MouseButton  { 
238+         use  MouseButton :: * ; 
239+         match  ( event_type,  raw_button. into ( ) )  { 
240+             ( MouseEventKind :: Moved ,  Left )  => Unidentified , 
241+             ( _,  button)  => button, 
242+         } 
243+     } 
244+ 
245+     /// Converts pixel coordinates to grid coordinates. 
246+      fn  pixels_to_grid_coords ( pixel_x :  u32 ,  pixel_y :  u32 ,  cell_size_px :  ( u32 ,  u32 ) )  -> ( u16 ,  u16 )  { 
247+         let  col = ( pixel_x / cell_size_px. 0 )  as  u16 ; 
248+         let  row = ( pixel_y / cell_size_px. 1 )  as  u16 ; 
249+         ( col,  row) 
250+     } 
252251} 
253252
254253/// Convert a [`web_sys::MouseEvent`] to a [`MouseButton`]. 
0 commit comments