Page 1 of 1
Dealing increment with scrollBar [Solved]
Posted: Sat May 17, 2014 11:02 am
by atout66
Hi to all,
I have some difficulties to understand how works the scrollbar in LC. I've seen the example provided by "martyknapp" from the LC's lessons, but it doesn't suite my need...
I have an horizontal scrollbar of 120px width. ShowValue is off because I show it in a custom field.
minValue = 1 ; maxValue = 9 ; lineInc = 1 ; pageInc = 1
My problem is that when the mouse (user) drag the slider, I'd like to have it moving step by step (from 1 to 2 ; from 2 to 3), and not from 1 to 1.1 ; 1.1 to 1.2 and so on in a smooth mode...
Well I want the slider to jump from one value to an other (not sure if I'm clear enough

)
Shall I calculate the pixels segment and deal with them or is there a pre build function in LC which does that ?
Thanks to read me,
Kind regards, Jean-Paul.
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 1:12 pm
by Klaus
Hi Jean-Paul,
sorry, no idea what you are after?
I created a scrollbar as described above and it showed WHOLE numbers 1 to 9,
no floating point as you described 1.1 etc.?
What did you script so far for the scrollbar?
Best
Klaus
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 2:30 pm
by atout66
Hi Klaus,
Sorry, my english is not that good...
What I mean is that I try to have the slider cursor to move with the mouse not smoothly but step by step; from one position (1) to an other (2) without the intermediate states.
So if the scrollbar start from 1 to 9, I should deal with 8 segments, step by step so that the cursor jump from one position to the next/previous one.
I agree, it doesn't show 0.1; 0.2; 0.3. It was just to help to figure out
It's the behavior with the <pageInc> as far as I know. If I click outside the slider cursor, it moves by a special increment, right ?
I thought the <lineInc> would do the same for the mouse on the slider cursor, but it doesn't...
Example, consider a line like the one below:
1 TAB 2 TAB 3 TAB 4 TAB 5
If I drag the slider from left to right, the slider will read the line above, in order from one to two:
1+space+T+A+B+space+2, and so on.
What I wonder is if it's possible to jump from the value 1 to 2 without the sequence <space+T+A+B+space>, step by step...
It was easy to do that with TBK, but I don't know if LC do the same?
Not sure to be clear enought, sorry
Thanks to read me,
Kind regards, Jean-Paul.
P.S.
Imagine as if it was the fan in your car. You have a graduated slider rotating from 0 to 5.
When you change from a zero position to one, there is no position 0.1.; 0.2; 0.3; 0.4, etc.
It is 0; 1; 2; 3; 4; 5, no intermediate stage.
There are points position it is easy to feel in the fingers (on some models of course!).
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 3:50 pm
by Klaus
Hm, sorry, still no idea what your scrollbar should do...
Do you already have a script for that scrollbar?
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 4:13 pm
by atout66
Hi Klaus,
Well, to be more precise my scrollbar has its type set to slider (I should have said that before!

).
I need to know what is the X position of the
cursor when I release the mouse (the slider is horizontal).
I already know its thumbPos with :
Code: Select all
put the thumbPos of me into laValeur
I have yet not found in the dictionary the function or property that lets you know what is the position (location) of the cursor itself...
If I find this <item 1 of the location of the cursor itself>, I can script my steps then
Don't misunderstand me... It's about the default cursor position provided by LC, in the tools palette, I care about; not the all scrollbar object, as its location doesn't move while draging the cursor
Thanks for your help, Jean-Paul.
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 4:16 pm
by Klaus
Aha!
"the mouseloc" will give you the current "cursor" (= mouse) position!
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 4:52 pm
by atout66
Arght !!!! Crasy
I thought it was a special function and you tell me mouseLoc()
Thanks Klaus, Jean-Paul.
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 4:58 pm
by atout66
Ahaha, too easy when you think about it...
As for now, the mouseLoc() doesn't "tell" me how to set the X location of
the cursor to the desired place I want

I can get its location but if I can't do nothing with it (the cursor), the problem stays.
So, it's not that easy at all in fact, you get me
Kind regards, Jean-Paul.
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 5:02 pm
by Klaus
Ah, I see, but it sounds like this is not possible with the built-in scrollbars in Livecode,
you cannot set their thumbpos to the mouseloc or anything!
You may want to "roll your own" scrollbar

Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 5:16 pm
by atout66
OK Klaus, I see.
you cannot set their thumbpos to the mouseloc or anything!
In fact I want to do the opposite...
From the <thumbPos> I know, and the <mouseLoc>, I'd like to move the cursor of the slider to a desired x location
But as its a build-in object, I was wondering if I could access some of its component.
Do you confirm that I can't ?
Kind regards, Jean-Paul.
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 5:27 pm
by Klaus
atout66 wrote:But as its a build-in object, I was wondering if I could access some of its component.
Do you confirm that I can't ?.
Yes, you can't!

Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 5:37 pm
by FourthWorld
While the thumbpos property is available only for separate scrollbar objects, the scrollbars on fields and groups have xScroll and vScroll properties which can be used similarly to position the current scroll amount.
Re: Dealing increment with scrollBar
Posted: Sat May 17, 2014 5:50 pm
by atout66
OK, thanks for your help.
I'm going to use the example provided by Marty's Sliders found in this forum but I don't know where anymore ?
Kind regards, Jean-Paul.
Re: Dealing increment with scrollBar [Solved]
Posted: Sun May 18, 2014 12:06 am
by Simon
Hi Jean-Paul,
I think this is what you want
Using Marty's Sliders stick this in;
Code: Select all
if round((xLoc-Lstop)*scaleFactor)+minValue > fld "theValue_h" then
set loc of me to xLoc-cX,yLoc
else if round((xLoc-Lstop)*scaleFactor)+minValue < fld "theValue_h" then
set loc of me to xLoc-cX,yLoc
end if
right under line 25, removing the original "set the loc of me..."
Fun!
Simon
Re: Dealing increment with scrollBar [Solved]
Posted: Wed May 21, 2014 3:50 pm
by atout66
Sorry, a little bit late to answer, but thanks anyway Simon
Every thing is allright now.
Kind regards, Jean-Paul.