-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to temporarily disable mouse input #3898
Comments
I think something like the below should work, although probably not recommended as it uses Textual internals. This is untested though as my terminal doesn't paste on mouse click. from textual.app import App, ComposeResult
from textual.widgets import Button, Input
class CustomInput(Input):
def on_focus(self) -> None:
self.app._driver._disable_mouse_support() # type: ignore
self.notify("Mouse support disabled")
def on_blur(self) -> None:
self.app._driver._enable_mouse_support() # type: ignore
self.notify("Mouse support enabled")
class ExampleApp(App):
def compose(self) -> ComposeResult:
yield CustomInput()
yield Button("Reset Focus")
if __name__ == "__main__":
app = ExampleApp()
app.run() |
@TomJGooding Thank you, your solution works - tested with Windows 10 and PuTTY/MobaXterm. I would still like to see a public method that would allow to achieve the same. |
Hey @jose1711, just to see if I understand correctly, you want Textual to stop handling events and to let the terminal handle them instead, right? |
If that means that Textual ignores mouse clicks but still receives key presses, then the answer is yes. |
What are you pasting that is causing a problem? Help us to understand the issue you are solving here. You may want to read https://label.dev/articles/xy-problem/ Most terminals support "bracketed paste mode", which means you can paste without having the terminal interpret escape sequences. |
@willmcgugan I think you might want to read the original issue post again. The use case is stated quite plainly and I don't understand how "bracketed paste mode" is relevant here? |
The OP was asking about pasting in to an input, which AFAIK works fine, and uses bracketed paste mode. Reading between the lines, if the context menu is not appearing, it might be because you need to press a modifier in application mode. Like ctrl or alt. I can't recommend mouse support as it will break user expectations. |
Good point about perhaps just needing a modifier! @jose1711 - could you confirm if shift+right-click works in application mode to paste? |
(Possibly related FAQ: https://textual.textualize.io/FAQ/#how-can-i-select-and-copy-text-in-a-textual-app) |
@willmcgugan thanks for the link on the XY problem. I'll strive to enhance my descriptions accordingly. Let me share a complete story. I utilized Textual to develop a small application for the support team within our company. Thanks to Textual, the development process was incredibly enjoyable, resulting in an application that surpasses the visual appeal of a standard shell script. Upon launching the program, users are prompted to enter a hostname. These hostnames can vary, with differences sometimes as subtle as a single letter (e.g., 'b' instead of 'd'). As users aim to avoid typos and expedite the process, they often prefer to paste hostnames from the clipboard. The majority of our users come from a Windows environment, where PuTTY serves as their primary tool for interacting with the Linux/Unix world. They've learned that right-clicking facilitates pasting, and instinctively try it in our application, only to encounter no response. This leads to the assumption that something is malfunctioning. Although the application mentions the use of Shift+Ins for pasting, altering user habits can be challenging, especially in time-sensitive scenarios where documentation is not thoroughly read. To address the need for pasting a single line of input and pressing Return, I'm considering suspending the output, as suggested by @TomJGooding . If you feel this use case is too specialized to deserve an implementation in a form of public method, I completely understand and will continue using the internal (private) method calls. |
@TomJGooding Indeed, it does. However, as mentioned in my more detailed description, it may 'feel' broken to less experienced users - especially those who find reading the manual a bit challenging. |
Closing as there doesn't seem to be much demand, and I'm not convinced it is a good idea. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
I would like to have an option to temporarily stop handling of mouse events by Textual. Use case would be a user which is used to paste input into terminal using right-click (PuTTY) and an application with a single
Input
widget.The application would disable handling of mouse events (application mode) temporarily while
Input
is in focus.I tried commenting
self._enable_mouse_support()
inlinux_driver.py
during experimenting but that did not work.The text was updated successfully, but these errors were encountered: