@@ -130,7 +130,20 @@ protected override void OnCreate(Bundle? savedInstanceState)
130130
131131 public override bool DispatchKeyEvent ( KeyEvent ? e )
132132 {
133- if ( e != null && KeyboardHandler != null && KeyboardHandler . HandleKeyEvent ( e ) )
133+ if ( e == null ) return false ;
134+
135+ // Intercept mouse back button which often triggers Keycode.Back
136+ if ( e . KeyCode == Keycode . Back && ( e . Source . HasFlag ( InputSourceType . Mouse ) || e . Source . HasFlag ( InputSourceType . Stylus ) ) )
137+ {
138+ if ( e . Action == KeyEventActions . Down )
139+ KeyboardHandler ? . HandleKeyEvent ( new KeyEvent ( KeyEventActions . Down , Keycode . Escape ) ) ;
140+ else if ( e . Action == KeyEventActions . Up )
141+ KeyboardHandler ? . HandleKeyEvent ( new KeyEvent ( KeyEventActions . Up , Keycode . Escape ) ) ;
142+
143+ return true ;
144+ }
145+
146+ if ( KeyboardHandler != null && KeyboardHandler . HandleKeyEvent ( e ) )
134147 return true ;
135148
136149 return base . DispatchKeyEvent ( e ) ;
@@ -157,6 +170,11 @@ public override bool DispatchTouchEvent(MotionEvent? e)
157170 handled = MouseHandler ? . HandleMotionEvent ( e ) ?? false ;
158171 }
159172
173+ // Stylus events should NEVER be passed to base.DispatchTouchEvent, as it triggers
174+ // Android's touch-mode which hides the cursor and shows touch effects.
175+ if ( isStylusEvent ( e ) )
176+ return handled ;
177+
160178 // In DeX mode, we MUST call base even if "handled" to ensure window focus and system gestures work.
161179 // However, if we fully consumed it (e.g. gameplay), we return true to prevent UI double-clicks.
162180 return base . DispatchTouchEvent ( e ) || handled ;
@@ -183,6 +201,11 @@ public override bool DispatchGenericMotionEvent(MotionEvent? e)
183201 handled = MouseHandler ? . HandleMotionEvent ( e ) ?? false ;
184202 }
185203
204+ // Stylus hover events should not be passed to base to avoid system-level hover effects
205+ // and touch-mode triggers.
206+ if ( isStylusEvent ( e ) )
207+ return handled ;
208+
186209 return base . DispatchGenericMotionEvent ( e ) || handled ;
187210 }
188211
0 commit comments