Skip to content

Scrollbar does not react on mouse #284

@certik

Description

@certik

I tested the code from #281 (comment), 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions