LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun Apr 05, 2009 8:10 pm
Hi, another Forum member asked about vertical scroll to control two or more fields. If one groups the fields and gives a vertical scrollbar to the group, this scrolls the actual fields rather than taking control of the fields' vertical scrollbars.
For the Script Collector prog I'm working on, I'd like to give the user an option to show horizontal lines between the lines of script (as text) in a field. (So i have one field non-opaque for collecting the script, and another underneath showing/hiding the rules). I've used the following code to show rules depending on how many lines there are in the script field:
Code: Select all
on mouseUp
put the number of lines in field "A" into tFnum
answer tFnum
put empty into field "B"
repeat with tRun = 1 to tFnum
put "_____________" into line tRun of field "B"
end repeat
end mouseUp
That works OK but if the scrollbar is "activated" in the first field, showing the scroll button, and likewise the field showing the rules underneath, I'd like to link them with a vertical scrollbar which would scroll the text in the two fields in tandem, rather than the actual fields themselves.
Is this possible, does anyone know please

-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Sun Apr 05, 2009 9:41 pm
I believe you can insert a standalone scrollbar and make it do what you want.
check out scrollbarbeginning, scrollbarend, scrollbardrag, scrollbarlinedec, scrollbarlineinc, and all the other scrollbar* stuffs in the dictionary.
Lots of interesting stuff in there i'm still trying to get a handle on.
gyroscope wrote:Hi, another Forum member asked about vertical scroll to control two or more fields. If one groups the fields and gives a vertical scrollbar to the group, this scrolls the actual fields rather than taking control of the fields' vertical scrollbars.
For the Script Collector prog I'm working on, I'd like to give the user an option to show horizontal lines between the lines of script (as text) in a field. (So i have one field non-opaque for collecting the script, and another underneath showing/hiding the rules). I've used the following code to show rules depending on how many lines there are in the script field:
Code: Select all
on mouseUp
put the number of lines in field "A" into tFnum
answer tFnum
put empty into field "B"
repeat with tRun = 1 to tFnum
put "_____________" into line tRun of field "B"
end repeat
end mouseUp
That works OK but if the scrollbar is "activated" in the first field, showing the scroll button, and likewise the field showing the rules underneath, I'd like to link them with a vertical scrollbar which would scroll the text in the two fields in tandem, rather than the actual fields themselves.
Is this possible, does anyone know please

-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun Apr 05, 2009 9:50 pm
Hi sturgis,
Thanks for reminding me of those. I've still got the problem of the group vertical scrollbar moving the fields themselves rather than what's in them...I'm sure it involves some of the stuff you mentioned but can't work out how...

-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Sun Apr 05, 2009 10:16 pm
How bout something like this?
edit: Don't know if you can do the same thing as this with the group scrollbar, but you can turn it off and add a seperate one and do as below.
Might be able to just turn on the scrollbar on one of the fields, not any others you want to layer and use this same code, but I used the scrollbar control seperately.
end edit
I have this script for the external scrollbar
Code: Select all
on scrollbarDrag newPosition
set the vscroll of field "first" to newPosition
set the vscroll of field "second" to newPosition
end scrollbarDrag
and this to adjust one of the scrollbar properties.
Code: Select all
set the thumbSize of scrollbar "Scrollbar1" to (the heigh of field "first" / the formattedHeight of group "first"
It works fine, both fields scroll at the same time, and since I have duplicate info in both I can confirm that they match up nicely.
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun Apr 05, 2009 11:16 pm
I have this script for the external scrollbar
Code:
Code: Select all
on scrollbarDrag newPosition
set the vscroll of field "first" to newPosition
set the vscroll of field "second" to newPosition
end scrollbarDrag
Hey sturgis, that's real neat, thank you!
Sorry to be slow here but where do you put the other bit of code please

-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Sun Apr 05, 2009 11:26 pm
gyroscope wrote:I have this script for the external scrollbar
Code:
Code: Select all
on scrollbarDrag newPosition
set the vscroll of field "first" to newPosition
set the vscroll of field "second" to newPosition
end scrollbarDrag
Hey sturgis, that's real neat, thank you!
Sorry to be slow here but where do you put the other bit of code please

You're not slow, i'm typo king today. Just make the whole thing like this. Put it all in the scrollbar script.
This works only for dragging, would have to do similar to capture the line increment, page increment stuff. But for a quick example of just dragging the thumb to control several fields, this works.
Code: Select all
on scrollbarDrag newPosition
set the thumbSize of me to (the height of field "first" / the formattedHeight of field "first")
set the vscroll of field "first" to newPosition
set the vscroll of field "second" to newPosition
end scrollbarDrag
edit:
To make the scrollbar look right you can also put
Code: Select all
set the startValue of me to 0
set the endValue of me to the formattedHeight of field "first"
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Mon Apr 06, 2009 12:17 am
It didn't seem to like those three lines in the scrollbarDrag handler (can't remember the error message) but the first bit of code works a treat for what I want, thank you!
By the way, the My Script Collector program this is for, I'll be "donating" to the Rev community when it's finished. I'll be putting a Thank You list in the splash screen so may I have your real name please, sturgis, to add to the list? (That's considering you want your name there, of course!)

-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Mon Apr 06, 2009 12:52 am
I'm kinda a recluse through lack of choice, and also through active choice. So no need to add me to the list, just glad to help.
This forum here is about the most interaction I have with.. well. anyone.
Not many forums where I feel comfortable enough to actually type things in, so this community must be something special.
If you can post your error message, maybe I can figure out if I typo-ed something, and how to fix it. My typers are a bit recalcitrant some days so who knows what I meant to type as apposed to what I actually typed.
gyroscope wrote:It didn't seem to like those three lines in the scrollbarDrag handler (can't remember the error message) but the first bit of code works a treat for what I want, thank you!
By the way, the My Script Collector program this is for, I'll be "donating" to the Rev community when it's finished. I'll be putting a Thank You list in the splash screen so may I have your real name please, sturgis, to add to the list? (That's considering you want your name there, of course!)

-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Mon Apr 06, 2009 1:09 am
So no need to add me to the list, just glad to help.
And that's appreciated!
Not many forums where I feel comfortable enough to actually type things in, so this community must be something special.
Yes, it's a friendly and helpful community, for certain. As Rev tends to be "three steps forward, two steps back" sometimes, there's always someone there to save the day.
If you can post your error message, maybe I can figure out if I typo-ed something, and how to fix it.
It show no errors when compiling but then says "Object can't set this property" so I realised this was in a 3rd field (to use the scrollbar of it) rather than a Scrollbar object. So it works fine now.
Thanks again for your help, sturgis.
