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!
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:
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.
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:
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.
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...
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
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.
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
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!)
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!)
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.