Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse support #186

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Mouse support #186

wants to merge 17 commits into from

Conversation

asmeurer
Copy link
Collaborator

This is based on #15. I removed commits that were unrelated to mouse support.

This still has some TODOs, so don't merge yet, but feel free to test.

livibetter and others added 16 commits July 20, 2011 11:46
The mouse events can still be considered a "key", and this makes the API
easier to understand.
This makes, for instance, right clicking on a line set the break point on that
line, not the currently selected line.
Except ones that don't "scroll", like the var stringifier cycling.
Double click doesn't actually work (it will likely be removed, as it requires
a real event loop). There's no reason to select a stack frame without entering
it, since no other actions exist on stack frames.
Unfortunately, there's no UI for this yet, unless you examine the breakpoint.
@asmeurer
Copy link
Collaborator Author

One main TODO here: This has supposed double click support, but it is based on the urwid main loop object. It doesn't work with the PuDB loop, because it doesn't keep track of that many keys. If you have a suggestion on how to make it work, that would be great. Otherwise, I'm going to delete it.

Second main TODO: I'm not married to any of the keybindings used here (most were taken from @livibetter's PR). I personally can't even type Ctrl-mouse or Meta-mouse in my terminal, and right-click only works if I disable the context menu in my terminal (which I don't particularly want to do). So suggestions on keybindings are very welcome.

@inducer
Copy link
Owner

inducer commented Jun 3, 2016

I think I can live without double click support for now.

I wonder if we should add "Add"/"Delete" buttons in a couple places to provide more things to click on.

I also wonder if "press" or "release" is the correct event to respond to. Buttons typically respond to "release". Many UI toolkits also emit a separate "click" event.

@asmeurer
Copy link
Collaborator Author

asmeurer commented Jun 3, 2016

Yeah, I'll remove the double click.

I didn't think about click vs. release. The selection (which is built into urwid) does the right thing in that when you click on a line and move the mouse, it moves with the mouse until you release. The mouse 2 items should definitely work on release, though.

@asmeurer
Copy link
Collaborator Author

asmeurer commented Jun 6, 2016

Just checked and the trivial thing, replacing, for instance

self.bp_list.listen_mouse_event("mouse press", 3, enable_disable_breakpoint)

with

self.bp_list.listen_mouse_event("mouse release", 3, enable_disable_breakpoint)

doesn't work. http://urwid.org/manual/userinput.html#mouse-release-events says that mouse release events often don't have button information. I haven't dug into this any further yet.

@inducer
Copy link
Owner

inducer commented Jun 6, 2016

So it doesn't seem that binding to release events is wise, realistically speaking. Fine by me--in that case we'll have to live with "press" events. Although that does explain why using a mouse in a terminal has always felt a bit weird. :)

@asmeurer
Copy link
Collaborator Author

asmeurer commented Jun 6, 2016

Judging by the non-working double click handler that was added by @livibetter, this is something that could likely be done in a not too difficult way if we used the urwid event loop, as it (apparently) keeps track of a history of mouse events. It might be possible to mock up something here as well, by keeping track of mouse events (but I'm unclear how difficult it would be). I may also contact the urwid guys to see if they have any suggestions here.

@inducer
Copy link
Owner

inducer commented Jun 6, 2016

I'm not certain that would be robust in the face of bizarreness, such as PRESS 1, PRESS 2, RELEASE ...

@asmeurer
Copy link
Collaborator Author

asmeurer commented Jun 6, 2016

urwid/urwid#192

@asmeurer asmeurer mentioned this pull request Jun 7, 2016
Base automatically changed from master to main March 8, 2021 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants