Skip to content

Most Mouse Deltas Rounded to Zero In Textual 2.0 #5554

Closed
@ddkasa

Description

@ddkasa

The Bug

Most mouse movement deltas are unusable due to being rounded to zero after the smooth scrolling update. Unless rapid mouse movements are applied, the deltas are almost certainly zero.

1.0.0

Textual-1.0.0.webm

2.0.4

Textual-2.0.4.webm

Expected behaviour would be the original, unless this was intended side effect when converting to integers to the new properties, as most of the float values are below/above ±0.5 depending on if its a negative value or not, so they get rounded to zero.

One idea would be to give the user access to the float values, but that seems a bit half baked, as the new properties would become mostly useless.

Another idea would be clamping the values to ±1 or the closest none-zero value.

MRE

from textual.app import App, ComposeResult
from textual.events import MouseMove
from textual.widgets import Placeholder


class BugReportApp(App):
    def on_mouse_move(self, event: MouseMove) -> None:
        print(f"{event.delta_x=} {event.delta_y=}")


if __name__ == "__main__":
    BugReportApp().run()

Textual Diagnostics

Versions

Name Value
Textual 2.0.4
Rich 13.9.4

Python

Name Value
Version 3.12.5
Implementation CPython
Compiler GCC 14.2.1 20240801 (Red Hat 14.2.1-1)
Executable /home/dk/dev/tmp/textual-sandbox/.venv/bin/python3

Operating System

Name Value
System Linux
Release 6.12.13-100.fc40.x86_64
Version #1 SMP PREEMPT_DYNAMIC Sat Feb 8 17:10:01 UTC 2025

Terminal

Name Value
Terminal Application Kitty
TERM xterm-kitty
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=274, height=54
legacy_windows False
min_width 1
max_width 274
is_terminal True
encoding utf-8
max_height 54
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