Simultaneously scrolling text vertically in two fields

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

urbaud
Posts: 118
Joined: Tue Feb 24, 2009 12:10 am
Location: Victoria, BC, Canada

Simultaneously scrolling text vertically in two fields

Post by urbaud » Mon Sep 25, 2023 2:11 am

I have a problem and everything I have tried so far doesn’t work. I even asked ChatGPT and Microsoft Bing if they could help me with the code and each one gave me samples of code, but none of the code worked. I think the apps and I are missing something—I think something simple. Anyway, this is the scenario: I have two text fields on a card, fld 1 and fld 2. Each has its vertical scroll bar showing because there is text in each. Field 1 (f1) has one number on each line: 1 to 20. Field (f2) has a letter of the alphabet on each line: a to t. I want to be able to scroll both fields simultaneously, such that number 1 in f1 is associated with a in f2, 2 with b, 3 with c, and so on. So, when I move the scroll bar in f1, the scroll bar in f2 also moves exactly with f1 and vice versa. I’m of the belief that Livecode can’t do this, however, I say this because I’m a newbie to Livecode—I don’t really know it very well. So, if it can be done and you can show me the code and I can get it to work I will be very appreciative and I’ll even share it with ChatGPT and Microsoft Bing so they can learn from you as I will learn from you. Is anyone out there up to the challenge?
Thanks, Dan
urbaud

scott_morrow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 29
Joined: Tue Jun 27, 2006 8:35 pm
Location: Bellingham, WA USA
Contact:

Re: Simultaneously scrolling text vertically in two fields

Post by scott_morrow » Mon Sep 25, 2023 4:54 am

Hello Dan,
There are several approaches to doing this but the underlying mechanism you probably want will be to catch the "scrollbarDrag" message.

The script of field "f1" might look like:

Code: Select all

on scrollbarDrag
  set the scroll of field "f2" to the scroll of me
end scrollbarDrag
Then you could do something similar in the script of field "f2"
Elementary Software
...now with 20% less chalk dust!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simultaneously scrolling text vertically in two fields

Post by richmond62 » Mon Sep 25, 2023 11:23 am

I think you must be careful to ensure BOTH of the fields are exactly the same size,so the amount they both scroll is identical.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Simultaneously scrolling text vertically in two fields

Post by jmburnod » Mon Sep 25, 2023 12:53 pm

Hi,
Two fields must have same text properties (font, size etc....)
Best regards
https://alternatic.ch

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

Re: Simultaneously scrolling text vertically in two fields

Post by dunbarx » Mon Sep 25, 2023 2:56 pm

Back in the Pleistocene, HC, which had no such message as "scrollbarDrag", had an XCMD called "MultiScroll", which I still use in the HC suite of stacks I manage. It was not a Rinaldi gadget, but still works just fine.

Craig

urbaud
Posts: 118
Joined: Tue Feb 24, 2009 12:10 am
Location: Victoria, BC, Canada

Re: Simultaneously scrolling text vertically in two fields

Post by urbaud » Mon Sep 25, 2023 4:52 pm

Hi Craig,

I have no idea what you mean by this: "Back in the Pleistocene, HC, which had no such message as "scrollbarDrag", had an XCMD called "MultiScroll", which I still use in the HC suite of stacks I manage. It was not a Rinaldi gadget, but still works just fine." What is HC and XCMD and a Rinaldi gadget?

Dan
urbaud

Klaus
Posts: 13855
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Simultaneously scrolling text vertically in two fields

Post by Klaus » Mon Sep 25, 2023 5:01 pm

Hi Dan,
urbaud wrote:
Mon Sep 25, 2023 4:52 pm
Hi Craig,

I have no idea what you mean by this: "Back in the Pleistocene, HC, which had no such message as "scrollbarDrag", had an XCMD called "MultiScroll", which I still use in the HC suite of stacks I manage. It was not a Rinaldi gadget, but still works just fine." What is HC and XCMD and a Rinaldi gadget?

Dan
then you are too young! :-D

HC = Hypercard and that was the grandfather and grandmother of all X-talk languages.
https://en.wikipedia.org/wiki/HyperCard
XCMDs were externals for HyperCard
Rinaldi was a french programmer who created a lot of HC XCMDs.


Best

Klaus

stam
Posts: 2722
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Simultaneously scrolling text vertically in two fields

Post by stam » Mon Sep 25, 2023 6:13 pm

urbaud wrote:
Mon Sep 25, 2023 4:52 pm
Hi Craig,

I have no idea what you mean by this: "Back in the Pleistocene, HC, which had no such message as "scrollbarDrag", had an XCMD called "MultiScroll", which I still use in the HC suite of stacks I manage. It was not a Rinaldi gadget, but still works just fine." What is HC and XCMD and a Rinaldi gadget?

Dan
He's just reminiscing the ancient history of this platform from around 35 years ago... Apple's HyperCard was revolutionary in many ways and sparked creation of similar platforms like SuperCard and MetaCard (the immediate ancestor of LiveCode) and many developers here have had some experience with HC. It was much more limited that LiveCode and many functions were provided via externals (written in C iirc).

If you want about 30 mins of entertainment learning more about HC and how it was perceived by general public back in the day have a look at this brilliant youtube video: https://www.youtube.com/watch?v=FquNpWdf9vg

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

Re: Simultaneously scrolling text vertically in two fields

Post by dunbarx » Mon Sep 25, 2023 7:23 pm

Young people today...

Craig

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

Re: Simultaneously scrolling text vertically in two fields

Post by dunbarx » Mon Sep 25, 2023 7:28 pm

Dan.

If anything is to be learned from this nonsense, know that with LiveCode Builder (I hesitate to use "LCB" in front of our nations youth) one can create, using low-level languages like "C", new "native" functionality. These sorts of, er, gadgets can then be attached to your LiveCode environment permanently, as if they were built into the language from the start.

Craig

urbaud
Posts: 118
Joined: Tue Feb 24, 2009 12:10 am
Location: Victoria, BC, Canada

Re: Simultaneously scrolling text vertically in two fields

Post by urbaud » Mon Sep 25, 2023 8:01 pm

Hi Klaus and Craig,

What does all of this XCMD and HC = Hypercard have to do with my asking for help to get text to scroll in two fields. And by the way, I'm 80 years old.

Dan. = confused old guy
urbaud

stam
Posts: 2722
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Simultaneously scrolling text vertically in two fields

Post by stam » Mon Sep 25, 2023 8:14 pm

urbaud wrote:
Mon Sep 25, 2023 8:01 pm
Hi Klaus and Craig,

What does all of this XCMD and HC = Hypercard have to do with my asking for help to get text to scroll in two fields.
Nothing at all, it’s just banter. Interesting, but not relevant to your issue.

The solution given above by @scott_morrow (the scrollbarDrag handler) already solves that.

urbaud
Posts: 118
Joined: Tue Feb 24, 2009 12:10 am
Location: Victoria, BC, Canada

Re: Simultaneously scrolling text vertically in two fields

Post by urbaud » Mon Sep 25, 2023 8:17 pm

Hey scott_morrow,

Thank you for the code snippet--it works like a charm. I appreciate the help. I don't do much coding in Livecode as it's just a hobby to help keep my old brain from deteriorating into dementia. Again, thanks for the help. And Craig, I don't get what you are trying to say to me, why not write it in more simple language, if you want to be helpful. But thank you for your input. You get 1 star and scott_morrow gets 4 stars.

Dan
urbaud

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

Re: Simultaneously scrolling text vertically in two fields

Post by dunbarx » Mon Sep 25, 2023 8:43 pm

Dan.

Ah. My first star.

I knew you already had the best solution, because LiveCode has native features to support mutual field scrolling, which was your original question.

I was therefore not really trying to help you in particular, no offense, just waxing nostalgic. Hypercard had no such message, so it was necessary to add such a feature by other means, an external command (XCMD).

And it was Klaus who assumed you were a young newbie. I would have as well, no offense. :wink:

I am only 72, and still use HC. Watch the video that Stam posted. This was probably made in 1988 or so.

Craig

urbaud
Posts: 118
Joined: Tue Feb 24, 2009 12:10 am
Location: Victoria, BC, Canada

Re: Simultaneously scrolling text vertically in two fields

Post by urbaud » Mon Sep 25, 2023 8:58 pm

Hi Craig,

I'm curious, what was it in my post that prompted you to start "waxing nostalgic"? And you assumed I was young, why? I actually found your reply to my post annoying, because I was looking for a solution to a problem I couldn't solve and you just "did your thing" I guess. I'm not on this forum much, so I don't have a sense as to how you usually reply to other's posts.

Dan
urbaud

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”