Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

added modifier key tracking in MouseEvents#6159

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

jerryz123
Copy link

Problem:
Currently, modifier keys in MouseEvents are only recognized if the FigureCanvas received a KeyEvent with the MouseEvent. However, in situations where the FigureCanvas does not receive keyboard focus, no KeyEvent is received, and thus the modifier-key is lost.

Solution
Modifier-key info should be carried in the MouseEvent created by a button_press_event. Add a modifiers field to mouse_events to track modifier-key status. I have updated the qt5 backend to account for this, but this can easily be extended to other backends.

@mdboom
Copy link
Member

Do you want to take a crack at making this work for the other backends?

@@ -1886,7 +1891,7 @@ def scroll_event(self, x, y, step, guiEvent=None):
step=step, guiEvent=guiEvent)
self.callbacks.process(s, mouseevent)

def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
def button_press_event(self, x, y, button, dblclick=False,modifiers=None,guiEvent=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please put new kwargs last.

@tacaswelltacaswell added this to the2.1 (next point release) milestoneMar 15, 2016
@jerryz123
Copy link
Author

I'll take a look.

@@ -254,8 +254,11 @@ def mousePressEvent(self, event):
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.pos().y()
button = self.buttond.get(event.button())
modifiers = "+".join([name for name, mod_key, qt_key in MODIFIER_KEYS
if (int(event.modifiers()) & mod_key) == mod_key])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe make modifiers aset instead of a string like"ctrl+alt"? Also, I think this could be simplified to

name for name, mod_key, _ in MODIFIER_KEYS if event.modifiers() & mod_key

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Since 2.1 is dropping 2.6 support, you write that in a set comprehension style.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We have already dropped 2.6 support (but test it on the 1.5.x because we are nice).

@njsmith
Copy link

You'll want to update the docs as well, both to mention the existence of.modifiers (so that people know it exists!), and probably also to modify the docs for for.key to explain its limitations and why.modifiers is better in most cases.

[FYI for context@mdboom@tacaswell:@jerryz123's an undergrad working with@stefanv and me on viscm-stuff, and this came out of that.]

@jerryz123
Copy link
Author

Could someone take a look at this?

I've added support for tk, gtk, qt, and wx.

@stefanv
Copy link
Contributor

@tacaswell Do you know who is familiar enough with the mac backend to give Jerry a hand?

@tacaswell
Copy link
Member

@mdboom probably. The mac backend just had some (major!) changes land. It
would be worth rebasing onto current master.

On Mon, Apr 4, 2016 at 10:43 PM Stefan van der Walt <
notifications@github.com> wrote:

@tacaswellhttps://github.com/tacaswell Do you know who is familiar
enough with the mac backend to give Jerry a hand?


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#6159 (comment)

@jerryz123
Copy link
Author

The mac backend appears to use modifiers to alter the button clicked. A Ctrl+Click registers as a right button click, while an Alt+Click registers as a middle button click.
src/_macosx.m

Should this be changed?

@tacaswell
Copy link
Member

I am leaning towards yes on changing the behavior of the mac backend. The single-button external mice seem to have died and I think on all of the fancy trackpads are now multi touch (so 2 and 3 finger taps/clicks are the right/middle mouse events).

@tacaswelltacaswell modified the milestones:2.2 (next next feature release),2.1 (next point release)Aug 13, 2017
@tacaswell
Copy link
Member

@jerryz123 Are you still interested in working on this?

@jerryz123jerryz123force-pushed themouse-event-modifiers branch 6 times, most recently from6d441fa to00ea2fbCompareAugust 13, 2017 09:05
@jerryz123
Copy link
Author

@tacaswell Sorry for the delay. I have adjusted the mac behavior so that modifier keys are preserved on mouse clicks.

What would be the correct way to get test coverage over modifier key behavior?

@tacaswell
Copy link
Member

We have some test of the qt5 backend which feed synthetic events through.

We don't have good tests for the other backends other than manually testing by devs.

@tacaswell
Copy link
Member

And the delay is as much on our side!

@jklymak
Copy link
Member

This seems useful if@jerryz123 or someone else had time to rebase and get it working again...

@tacaswelltacaswell modified the milestones:v3.1.0,v3.2.0Feb 24, 2019
@tacaswelltacaswell modified the milestones:v3.2.0,v3.3.0Aug 25, 2019
@QuLogicQuLogic modified the milestones:v3.3.0,v3.4.0May 27, 2020
@jklymakjklymak marked this pull request as draftSeptember 8, 2020 02:01
@QuLogicQuLogic modified the milestones:v3.4.0,v3.5.0Jan 21, 2021
@tacaswelltacaswell modified the milestones:v3.5.0,v3.6.0Aug 5, 2021
@timhoffmtimhoffm modified the milestones:v3.6.0,unassignedApr 30, 2022
@story645story645 modified the milestones:unassigned,needs sortingOct 6, 2022
@anntzer
Copy link
Contributor

Superseded by#23473. Thanks for initiating the work on this!

@tacaswelltacaswell removed this from thefuture releases milestoneDec 16, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

10 participants
@jerryz123@mdboom@njsmith@stefanv@tacaswell@jklymak@anntzer@QuLogic@story645@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp