Dealing increment with scrollBar [Solved]

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Dealing increment with scrollBar [Solved]

Post by atout66 » Sat May 17, 2014 11:02 am

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.
Last edited by atout66 on Sat May 17, 2014 5:50 pm, edited 3 times in total.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Dealing increment with scrollBar

Post by Klaus » Sat May 17, 2014 1:12 pm

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

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar

Post by atout66 » Sat May 17, 2014 2:30 pm

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 :idea:

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 :mrgreen:

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!).
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Dealing increment with scrollBar

Post by Klaus » Sat May 17, 2014 3:50 pm

Hm, sorry, still no idea what your scrollbar should do...
Do you already have a script for that scrollbar?

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar

Post by atout66 » Sat May 17, 2014 4:13 pm

Hi Klaus,

Well, to be more precise my scrollbar has its type set to slider (I should have said that before! :roll: ).
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 :wink:

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.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Dealing increment with scrollBar

Post by Klaus » Sat May 17, 2014 4:16 pm

Aha! :D

"the mouseloc" will give you the current "cursor" (= mouse) position!

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar

Post by atout66 » Sat May 17, 2014 4:52 pm

Arght !!!! Crasy :shock:
I thought it was a special function and you tell me mouseLoc() :D

Thanks Klaus, Jean-Paul.
Discovering LiveCode Community 6.5.2.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar

Post by atout66 » Sat May 17, 2014 4:58 pm

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 :idea:
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 :wink:

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Dealing increment with scrollBar

Post by Klaus » Sat May 17, 2014 5:02 pm

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 :D

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar

Post by atout66 » Sat May 17, 2014 5:16 pm

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.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Dealing increment with scrollBar

Post by Klaus » Sat May 17, 2014 5:27 pm

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! 8)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10053
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Dealing increment with scrollBar

Post by FourthWorld » Sat May 17, 2014 5:37 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar

Post by atout66 » Sat May 17, 2014 5:50 pm

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.
Discovering LiveCode Community 6.5.2.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Dealing increment with scrollBar [Solved]

Post by Simon » Sun May 18, 2014 12:06 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Dealing increment with scrollBar [Solved]

Post by atout66 » Wed May 21, 2014 3:50 pm

Sorry, a little bit late to answer, but thanks anyway Simon :wink:
Every thing is allright now.

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Post Reply