question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mouse support not working on Windows - potential fix, and interaction with ScrollablePane

See original GitHub issue

I have a prompt_toolkit application which has mouse_support=True in its Application call. The mouse support works fine on OS X and Linux, but nothing happens when clicking on controls when running on Windows.

I’ve seen various issues on here about this (#1232, #1177 and #1059) and there are various fixes proposed.

The fix in #1177 partially worked for me, but also caused other issues. This fix changes a check from checking for an object being a Win32Output instance, to checking for either a Win32Output or Windows10_Output instance. Altering the code as suggested in that issue led to a few other errors being raised - one of which I think is related to the work in #1347, where the way that mouse handlers are stored is changed, and this bit of code hasn’t been updated.

I think I’ve managed to fix it, with the code looking this in the end:

from prompt_toolkit.output.win32 import Win32Output
from prompt_toolkit.output.windows10 import Windows10_Output

if isinstance(output, Win32Output) or isinstance(output, Windows10_Output):
    screen_buffer_info = output.get_win32_screen_buffer_info()
    rows_above_cursor = (
        screen_buffer_info.dwCursorPosition.Y - event.app.renderer._cursor_pos.y
    )
    y -= rows_above_cursor

    # Call the mouse event handler.
    handler = event.app.renderer.mouse_handlers.mouse_handlers[x, y]
    handler(MouseEvent(position=Point(x=x, y=y), event_type=event_type))

I ran into a few issues where it seemed like the mouse positions weren’t being reported quite correctly (possibly due to issues with the ScrollablePane?), but I can’t seem to reproduce them properly - so it might not be a problem. I’d be grateful for your experienced eye over the code though.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jonathanslenderscommented, Feb 23, 2021

Hi @625781186 , yes that is possible. It’s something I intend to do.

0reactions
625781186commented, Feb 23, 2021

@jonathanslenders Is it possible to add a click event to the scroll bar? I’ll try to add a drag event to the scroll bar. But don’t know how to trigger a scroll bar mouse event

Read more comments on GitHub >

github_iconTop Results From Across the Web

No Mouse support in Windows 10 · Issue #1059
But cannot scroll in Windows 10 command prompt... ... Mouse support not working on Windows - potential fix, and interaction with ...
Read more >
python-prompt-toolkit
I was wondering whether it is possible to swap the Vt100Input class for a class which offers genuinely less capabilities (i.e. no cursor...
Read more >
Reference — prompt_toolkit 3.0.36 documentation
Run function on the terminal above the current application or prompt. What this does is first hiding the prompt, then running this callable...
Read more >
Crazy Eddie's GUI System: Change Log
Bug Fix: ScrollablePane issues: Broken hit-testing of content initially outside the view pane (this was broken in 0.7.0 when inner-rect fix was made)....
Read more >
office-ui-fabric-react/CHANGELOG.md
1069, - A bug fix to avoid crash in ScrollablePane when the componenent is unmounted in an environment where MutationObserver is not supported...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found