prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Scrollbar does not react on mouse

Open
#284 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

I tested the code from https://github.com/jonathanslenders/python-prompt-toolkit/issues/281#issuecomment-217122767, i.e.:

from __future__ import unicode_literals
from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.document import Document
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.interface import CommandLineInterface
from prompt_toolkit.key_binding.manager import KeyBindingManager
from prompt_toolkit.keys import Keys
from prompt_toolkit.layout.containers import Window
from prompt_toolkit.layout.controls import BufferControl
from prompt_toolkit.layout.margins import ScrollbarMargin
from prompt_toolkit.shortcuts import create_eventloop


manager = KeyBindingManager()

def get_default_text():
    return '\n'.join('%s' % i for i in range(100))


@manager.registry.add_binding(Keys.ControlQ, eager=True)
@manager.registry.add_binding(Keys.ControlC, eager=True)
def _(event):
    event.cli.set_return_value(None)

app = Application(
    layout=Window(
        content=BufferControl(buffer_name=DEFAULT_BUFFER),
        right_margins=[ScrollbarMargin(display_arrows=True)]),
    buffers={
        DEFAULT_BUFFER: Buffer(
            initial_document=Document(get_default_text(), 0))
    },
    key_bindings_registry=manager.registry,
    mouse_support=True,
    use_alternate_screen=True
)

eventloop = create_eventloop()
try:
    cli = CommandLineInterface(application=app, eventloop=eventloop)
    cli.run(reset_current_buffer=False)
finally:
    eventloop.close()

and it shows a scrollbar on the right, but even though mouse_support is enabled, no matter how I click or drag on the scrollbar, nothing happens.

Mouse support itself works, e.g. in examples/mouse-support.py.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied Application reproducer, focusing on ScrollbarMargin and the mouse-support path; compare its behavior with examples/mouse-support.py. Done means clicking and dragging the displayed scrollbar changes the buffer view while mouse_support remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.