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

key events handler return value to True to stop propagation #6397

Merged
merged 2 commits into from May 12, 2016

Conversation

fariza
Copy link
Member

@fariza fariza commented May 11, 2016

Fixing #6349

Right now only stopping the key press and key release event from propagating after callback.
I am in doubt about the other events, should be stopped also?

@tacaswell how does it work in Qt?

@fariza fariza changed the title key events handler return value to False to stop propagation key events handler return value to True to stop propagation May 11, 2016
@tacaswell
Copy link
Member

Qt does not have this notion of a 'callback' chain. Each signal can propagate to 0 or more slots, but they are, my understanding, all independently executed.

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone May 11, 2016
@@ -300,14 +300,14 @@ def key_press_event(self, widget, event):
key = self._get_key(event)
if _debug: print("hit", key)
FigureCanvasBase.key_press_event(self, key, guiEvent=event)
return False # finish event propagation?
return True # stoping event propagation
Copy link
Member

Choose a reason for hiding this comment

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

"stopping", not "stoping", but actually, just use "stop".

@dopplershift
Copy link
Contributor

@tacaswell Qt's signals/slots mechanism is separate from its event handling (like keyboard events). Qt's event handling does have the notion of stopping the propagating of events.

@tacaswell
Copy link
Member

@tacaswell
Copy link
Member

On a bit further reading, the notion of event propagation is handled by the method event in QObject which by default dispatches to a set of eventtypeEvent methods (all of which are void functions at the c++ layer) which we override. This 'accepts' the event and prevents propagation up to the parent widgets. We could re-enable that propagation by calling the default implementation of any of those methods, but as written of the Qt events are stopped by our handlers.

https://doc.qt.io/qt-4.8/qwidget.html#event

@fariza
Copy link
Member Author

fariza commented May 12, 2016

So with the changes in this PR we are at the same level that Qt

@tacaswell tacaswell merged commit 37a3baf into matplotlib:master May 12, 2016
tacaswell added a commit that referenced this pull request May 12, 2016
MNT: key events handler return value to True to stop propagation it gtk
@tacaswell
Copy link
Member

backported to 2.x as 9b39f3e

@fariza fariza deleted the stop-gtk-key-event-propagation branch May 17, 2016 22:05
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

5 participants