Disable mouse #183
-
Having mouse support in textual is amazing, but for some things I'd love to be able to disable it completely. Is there any way to turn off mouse events? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Textual doesn't currently have a setting that will do this, but you could roll a widget like this: class NoMouse( Static ):
"""Mouse killing widget."""
DEFAULT_CSS = "NoMouse {display: none;}"
def on_mount( self ):
self.capture_mouse( True ) and compose it into your app and it should (it does in my testing) eat all the mouse vents. |
Beta Was this translation helpful? Give feedback.
-
I can think of a few ways of hacking that in. We could also expose that via a simple method on App perhaps. But what is the use-case? Where would you want to disable the mouse? Easiest way I can think of currently is to catch the mouse events on app. Something like this: async def on_event(self, event: events.Event) -> None:
if isinstance(event, MouseEvent):
event.prevent_default() |
Beta Was this translation helpful? Give feedback.
I can think of a few ways of hacking that in. We could also expose that via a simple method on App perhaps. But what is the use-case? Where would you want to disable the mouse?
Easiest way I can think of currently is to catch the mouse events on app. Something like this: