[ SOLVED] Strange behaviour with Scrollbars

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Iluvatar
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 8
Joined: Fri Apr 09, 2010 8:59 am

[ SOLVED] Strange behaviour with Scrollbars

Post by Iluvatar » Sun Mar 10, 2013 9:26 am

I am new to LiveCode and wanted to try out Zoom & Pan with a test application.

I have tried to use scrollbars and have come up with some curious results. I don't know if it is me or what, but here goes....

I've attached a stripped-down app comprising a scroll bar (one axis of pan) and a zoom (using little buttons). My intention was to use this to zoom and pan a graphic.

The app consists of 3 components: the stack script ("Test Zoom_Scroll.src") and the scrollbar scripts ("Zoombar" and "Scrollbar").

A couple of problems exist:

1] When you FIRST execute this app it doesn't have the scrollbars enabled (or the app doesn't execute). You have to "start" it with the Tools Palette. Is this normal?

2] The Scrollbar script is supposed to handle any movement of the scrollbar. However, I am unable to get the program to recognise the initial Properties settings of the 'reset_scrollbar' routine. It seems to ignore them and start with particular defaults (e.g. lineInc = 2).

3] Stranger still, the result is not regular. I you click on the right arrow of the scrollbar, the displayed number (the 'thumbposition' of the bar) increments using a strange progression (instead of by 1). It uses: 0, 2, 5, 7, 9, 11, 14, 16, 18, 20, 23, 25, 27, 29, 32... etc I guess it may become regular and one could construct a formula for generating the series. It should be: 0,1,2,3,4,5,6,7..... etc

The Zoom bar seems to behave well. It is intended to zoom from 0 to 90 in steps of 10.

Can anyone point a finger at what is going on here? :? I am going insane !!!
Attachments
Copy Test Zoom_Scroll.zip
(3.01 KiB) Downloaded 210 times
Last edited by Iluvatar on Wed Mar 13, 2013 11:21 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Strange behaviour with Scrollbars

Post by dunbarx » Sun Mar 10, 2013 5:54 pm

I have not looked deeply into your stack, but I do know that you cannot expect perfect results from scrollbar positioning. The width of the thumb has an effect, in that it interacts with the math as one calculates the thumbposition in relation to the end value.

Try it. Change the size of the thumb itself to a much smaller value, like 4, and you will find that a click on one of the arrows may not even increment the displayed value, though a few more clicks will. This actually makes sense, the number of pixels as measured across the width of the scrollbar itself not meshing exactly with the parameters selected for the control. So even though you specify an increment value for each arrow click, LC still has to do the math, so to speak, and does its best. You can get your expected values, if that is important for each distinct arrow click, by tweaking those parameters.

Hah. Try this with a thumb width of 0.

Craig Newman

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Strange behaviour with Scrollbars

Post by magice » Sun Mar 10, 2013 5:57 pm

Hello and welcome
Iluvatar wrote:I am new to LiveCode and wanted to try out Zoom & Pan with a test application.

I have tried to use scrollbars and have come up with some curious results. I don't know if it is me or what, but here goes....

I've attached a stripped-down app comprising a scroll bar (one axis of pan) and a zoom (using little buttons). My intention was to use this to zoom and pan a graphic.

The app consists of 3 components: the stack script ("Test Zoom_Scroll.src") and the scrollbar scripts ("Zoombar" and "Scrollbar").

A couple of problems exist:

1] When you FIRST execute this app it doesn't have the scrollbars enabled (or the app doesn't execute). You have to "start" it with the Tools Palette. Is this normal?
Unless I am completly misunderstanding you, I cannot duplicate this problem unless you are meaning that you have to switch to run mode, which is perfectly normal
Iluvatar wrote: 2] The Scrollbar script is supposed to handle any movement of the scrollbar. However, I am unable to get the program to recognise the initial Properties settings of the 'reset_scrollbar' routine. It seems to ignore them and start with particular defaults (e.g. lineInc = 2).
read about pageIncrement in the dictionary. There is a note there that reads "The amont the scrollbar moves will equal the pageIncrement minus the lineIncrement." I think that may be part of your problem. your script sets the page increment to 36, your line increment is 2 so it will move 34.
Iluvatar wrote: 3] Stranger still, the result is not regular. I you click on the right arrow of the scrollbar, the displayed number (the 'thumbposition' of the bar) increments using a strange progression (instead of by 1). It uses: 0, 2, 5, 7, 9, 11, 14, 16, 18, 20, 23, 25, 27, 29, 32... etc I guess it may become regular and one could construct a formula for generating the series. It should be: 0,1,2,3,4,5,6,7..... etc
In the basic properties for the scroll bar, you will see a section named "Scroll Distance" set the "On arrow click" to 1 That is your lineIncrement, so if you set that to 1 and your pageIncrement to 37 i think you will see the results you are looking for. By the way, these settings will save with the stack, so unless your gMax_data_points variable will be changing in the final version there is no need for the reset script. Other then that, your globals would be better suited to be saved as custom properties of the scroll bars.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Strange behaviour with Scrollbars

Post by magice » Sun Mar 10, 2013 6:14 pm

Ahhh...I see more of your problem. Look at the proportionalThumbs property in the dictionary. It looks like when you change the thumbSize, it resets the lineIncrement to 2 to maintain proportion.

Iluvatar
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 8
Joined: Fri Apr 09, 2010 8:59 am

Re: [ SOLVED] Strange behaviour with Scrollbars

Post by Iluvatar » Wed Mar 13, 2013 11:23 pm

magice

Thanks for the help. You wre correct. I removed the restriction on the thumbSize and it all fell into place. It seems that LiveCode didn't like to be restricted so I removed it.

The scrollbar now scrolls in line increments of 1 !

Thanks again ! :)

Post Reply