control hscroll of one field by another field

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
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

control hscroll of one field by another field

Post by Da_Elf » Mon Dec 11, 2017 9:39 pm

I would like that when i scroll one field another field with automatically scroll along with the first field. Its because i want to have a title field for rows in a table that will remain on top when scrolling down but when scrolling sideways the titles in the upper field will remain locked with the rows in the table. in excel it would be like clicking "freeze panes"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: control hscroll of one field by another field

Post by dunbarx » Mon Dec 11, 2017 9:49 pm

This is done by setting the scroll of your "slave" field to the scroll of your "master" field. Put this in the script of the "master":

Code: Select all

on scrollbarDrag
   set the scroll of fld 2 to the scroll of me
end scrollbarDrag
Now this assumes, for example, that the textSize of each field is the same. You can probably see why. Of course, one can fix that as well.

Right?

Craig Newman

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: control hscroll of one field by another field

Post by Da_Elf » Mon Dec 11, 2017 10:00 pm

ah ha! i was using set hscroll of fld "title" to the hscroll of me but it was the scrollbarDrag that was the key piece i needed. thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: control hscroll of one field by another field

Post by dunbarx » Mon Dec 11, 2017 11:24 pm

Hi.
...i was using set hscroll of fld "title" ...
You probably could, but the message is the thing, not the property, if you know what I mean.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”