Problems setting a scroll view position via code.

223 views
Skip to first unread message

Fernando Coelho

unread,
Apr 26, 2015, 11:57:13 PM4/26/15
to kivy-...@googlegroups.com
Hey there guys, I am having some trouble in my desktop application when I try to set a position to a scroll view.

I have this same problem in two parts of the code, I need to set to position of the scroll view according to the iteration with another widget.
Here is what I have:


        self._layout.scroll_x = relativeX
       
self._layout.scroll_y = relativeY


Where relative x and y are the position touched in the other widget divided by its size.

When I use this code, the scroll view shows the desired position, but when I try scroll by dragging the mouse in the scroll view, it will imediately return to the position it was last manually scrolled (or the initial position if the scroll view had not been manually scrolled yet).

This is probably due to some state variable that is saving the last touch the scroll view received.
Does anyone know how to do this properly? Is there any code to reset the controll variables of the scroll view that would help me?

Thanks in advance.

Kived Devik

unread,
Apr 27, 2015, 10:55:00 AM4/27/15
to kivy-...@googlegroups.com

That should be working, but do I remember this being an issue before. Are you using the latest Kivy, version 1.9.0?

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fernando Coelho

unread,
Apr 27, 2015, 12:40:35 PM4/27/15
to kivy-...@googlegroups.com
No, I am currently using 1.8, the program is target at linux (I am testing on ubuntu) and on windows (I am testing on 7 and 8).

I tried updating and re-instaling kivy on ubuntu last week and the stable version was still 1.8, which is the reason I kept using it. Would it work on 1.9?

Kived Devik

unread,
Apr 27, 2015, 1:13:30 PM4/27/15
to kivy-...@googlegroups.com

Ubuntu doesn't always have the newest versions for many packages. The best way to update Kivy on Ubuntu is via the PPA:

sudo apt-add-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get upgrade

--

Fernando Coelho

unread,
Apr 27, 2015, 11:56:33 PM4/27/15
to kivy-...@googlegroups.com
Tried on kivy 1.9, but I got the same error...
Some really strange bugs:
If I try to scroll to the top-most point of the screen, it sometimes work.
It is possible to make the scrollview stop working with some combinations of scrolls.

Not much ideas of what else to do, I guess I will try to read the code and check if there is any protected method that I can call that will solve my issue.

Thanks for the help.

Fernando Coelho

unread,
Apr 28, 2015, 3:02:52 PM4/28/15
to kivy-...@googlegroups.com
Updating the information on this issue:

- Happens on 1.9.1 dev as well (I compiled kivy from master today, same issue).

There have been a question here some time ago with no answer found:
- https://groups.google.com/forum/#!topic/kivy-users/50ZSa5V5xsM

There have been an issue registere in the git that should have fixed the problem:
- https://github.com/kivy/kivy/issues/1078

I tried several things myself, but couldn't get show the touch is being handled.
The really strange thing is thar it has no grabed touch and touch.ud is empty as is the touch stack and srcollview._touch is None.

Where the hell is the info of the last touch comming? u,u

Well, I will keep trying and leave an answer here if I find it.

Fernando Coelho

unread,
Apr 30, 2015, 5:54:16 PM4/30/15
to kivy-...@googlegroups.com
Found a work around:

Save a flag to show that that a forced scroll was issued.

When handling the touch down in the scroll view, verify if the flag set, in this case call the default touch down function (if you overrode it), then the default touch up and then handle the touch as you normally would and unset the flag. Basically you simulate a simple touch in the and then proceed to handle the touch normally.

Hope this helps.

Mihály Mirk

unread,
Oct 25, 2016, 8:06:16 AM10/25/16
to Kivy users support
The Workaround works only if the  "scroll_type" is "content".

If the scroll_type is only "bars", it won't work...
Reply all
Reply to author
Forward
0 new messages