prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.37k stars 716 forks source link

Redirect mouse input to non-focused window #781

Open Martmists-GH opened 6 years ago

Martmists-GH commented 6 years ago

I'm writing an application with a BufferControl as log, and TextArea for input. I would like to redirect scrolling to scroll the buffer, but keep the input window in focus. How would you recommend I tackle this issue?

The docs say nothing about mouse-input in the keybinds section, so I'm wondering what to use as buttons.

Martmists-GH commented 6 years ago

using the following code (with mouse_support=True) still does not seem to work:

        @kb.add(Keys.ScrollUp)
        def sup(_):
            self.out_window._scroll_up()  # pylint: disable=protected-access

        @kb.add(Keys.ScrollDown)
        def sdown(_):
            self.out_window._scroll_down()  # pylint: disable=protected-access
rigogsilva commented 5 years ago

Maybe this can help you: https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/prompt_toolkit/layout/containers.py#L2114

Or this: https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/prompt_toolkit/layout/menus.py#L131