Skip to content

GLViewWidget: don't assume mouse tracking is disabled#2653

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:dont-assume-mousetracking-off
Mar 18, 2023
Merged

GLViewWidget: don't assume mouse tracking is disabled#2653
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:dont-assume-mousetracking-off

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Mar 17, 2023

In mouseMoveEvent, it is assumed that self.mousePos has already been set. This amounts to assuming that there is at least one mousePressEvent prior to mouseMoveEvent.

This amounts to assuming that mouse tracking is left at its default disabled state.

This PR removes this assumption and simplifies the code by removing the mousePressEvent handler altogether.

Relevant documentation: https://doc.qt.io/qt-6/qwidget.html#mouseMoveEvent
"If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed."

This is partially related to the GLViewWindow implementation in #2650. In a QOpenGLWindow, there is no mouse tracking enable/disable.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Mar 18, 2023

Thanks @pijyoi always love to see the code cleaned up and unnecessary methods removed.

@j9ac9k j9ac9k merged commit e7f3934 into pyqtgraph:master Mar 18, 2023
@pijyoi pijyoi deleted the dont-assume-mousetracking-off branch March 18, 2023 03:40
@l-spiecker
Copy link
Copy Markdown

I now had to set the following to not jump between mouse clicks and keep the behaviour the a same as before.

w = gl.GLViewWidget()
w.setMouseTracking(True)

(Using pyqt5)

@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented Apr 19, 2023

Hi @l-spiecker , thank you for the bug report and sorry for having caused the bug!
I have tried to fix it in #2698. Would you be able to test it out?

@l-spiecker
Copy link
Copy Markdown

Nice, works now again. Thanks!

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.

3 participants