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

Scrolling instead of zooming #23

Open
zhrexl opened this issue Mar 16, 2020 · 7 comments
Open

Scrolling instead of zooming #23

zhrexl opened this issue Mar 16, 2020 · 7 comments

Comments

@zhrexl
Copy link

zhrexl commented Mar 16, 2020

Hey,
if you want to stop scrolling when the mouse is above the plot you can overwrite the QScrollArea's eventfilter
self.scrollArea.viewport().installEventFilter(self)

and then do something like that:
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.Wheel:
if self.Plot.underMouse():
return True

I thought you might be looking for something like that.

@kangalio
Copy link
Owner

Wow I didn't even see this.

Haha it feels so great to have other people's activity on here. And yes, I've been very much looking for that. My temporary solution was to disable the mouse wheel completely. But I'll try your solution out.

kangalio added a commit that referenced this issue May 1, 2020
@kangalio
Copy link
Owner

kangalio commented May 1, 2020

Implemented in e0a6211, works. I now realize that this does effectively the same thing as what I had before (previously all scroll events on ScrollArea were blocked, now only scroll events above the plot are blocked; which comes out as the same thing because the ScrollArea consists of nothing but said plot), but it doesn't matter :)

I plan to move the text boxes to Qt text boxes anyway, which would make this change worthwhile.

@kangalio kangalio closed this as completed May 1, 2020
@zhrexl
Copy link
Author

zhrexl commented May 1, 2020

Sorry, somehow i managed to write down the opposite of what I was thinking and didn't even it realize up to now.

We should make use of QWidget.hasFocus() property and/or the QWidget::focusInEvent to achieve a better result, the idea is that it will only zoom in/out if the user previously clicked on the plotwidget, otherwise it will keep out of focus and as a result not zooming.

I'm a little bit rusty in PyQt but will definitely give it a try in the next weekend.

@kangalio
Copy link
Owner

kangalio commented May 1, 2020

That's a neat idea. Though I'm a little afraid that having to click onto a widget in order to be able to interact with it is unintuitive.

I'll reopen this issue, I think..?

@kangalio kangalio reopened this May 1, 2020
@zhrexl
Copy link
Author

zhrexl commented May 1, 2020

It is bit unintuitive for sure but I guess its the standard approach in this case, if you think in a more intuitive way let me know it, I'm really interested in a new approach 🤔

@kangalio
Copy link
Owner

kangalio commented May 1, 2020

In my opinion it would be best to allow scrolling everywhere except right in the middle of plots. Basically everywhere on this image where I marked red:
image

Additionally, it would be great to have the same behavior that browser apply for scroll areas inside scroll areas. Idk if you've ever seen that, but browsers have a smart and simple way to decide whether the user intended to scroll the inner or the outer scroll area. It's kinda hard to explain and I can't find a document explaining the behavior.

Anyway, I'd have no idea how to implement all that lol

@kangalio
Copy link
Owner

kangalio commented May 11, 2020

Update:

I did a big restructure of how the plots are rendered. All plots used to be embedded in one big GraphicsLayoutWidget (class from pyqtgraph). It used to be impossible to detect whether a scroll event happened on a plot or on the padding between plots - it was all part of the GraphicsLayoutWidget black box.

Now, everything that can be done in Qt is done in Qt. Among fixing other issues (weird plot squashing and limited window shrinking capabilities) it made it possible to implement exactly what I described in the edited screenshot above.

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

No branches or pull requests

2 participants