Skip to content

Mouse capture issues on Windows #5894

@imAKAYEE

Description

@imAKAYEE

Have you checked closed issues? (https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed) - yes

Have you checked against the most recent version of Textual? (https://pypi.org/search/?q=textual) - yes

The bug

Here is the code to replicate the issue:

from textual.app import App, ComposeResult
from textual.widgets import Label, Input

class MouseTrackerApp(App):
    def compose(self) -> ComposeResult:
        yield Input(placeholder="this is input")

    def on_mount(self) -> None:
        self.query_one(Input).focus()

if __name__ == "__main__":
    app = MouseTrackerApp()
    app.run(mouse=False)

On a unix system everything works properly, mouse is disabled and nothing happens. When I run this code on Windows however, everytime I move my mouse the Input gets polluted with lots of data. It only happens when mouse=False is present in the run method, otherwise everything works. Also, after exiting the whole python script, the terminal starts to get polluted with the same data as well when moving mouse

I've checked this on two Windows systems. On the first one I've used Windows Terminal with Git Bash, later, PowerShell. And in the end, I've tried it with Git Bash itself (both the terminal application and shell). In each combination I've encountered the problem with Input being polluted and the terminal being polluted as well after exiting the python script. On the second system I've checked it in the same way and here the results were different. When using Windows Terminal with Git Bash/PowerShell everything was fine with the Input, however the terminal was still being polluted with data after exiting the script. When using Git Bash (both the terminal application and shell) the Input is polluted as well as the terminal

I've pasted diagnostics from the second Windows system

Textual Diagnostics

Versions

Name Value
Textual 3.5.0
Rich 14.0.0

Python

Name Value
Version 3.12.0
Implementation CPython
Compiler MSC v.1935 64 bit (AMD64)
Executable C:\Users\AKAYEE\textual\venv\Scripts\python.exe

Operating System

Name Value
System Windows
Release 11
Version 10.0.26100

Terminal

Name Value
Terminal Application Windows Terminal
TERM xterm-256color
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=120, height=30
legacy_windows False
min_width 1
max_width 120
is_terminal True
encoding utf-8
max_height 30
justify None
overflow None
no_wrap False
highlight None
markup None
height None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions