Simultaneously scrolling text vertically in two fields
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Simultaneously scrolling text vertically in two fields
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
Thanks, Dan
urbaud
-
- 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
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:
Then you could do something similar in the script of field "f2"
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
Elementary Software
...now with 20% less chalk dust!
...now with 20% less chalk dust!
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Simultaneously scrolling text vertically in two fields
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.
-
- 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
Hi,
Two fields must have same text properties (font, size etc....)
Best regards
Two fields must have same text properties (font, size etc....)
Best regards
https://alternatic.ch
-
- 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
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
Craig
Re: Simultaneously scrolling text vertically in two fields
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
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
Re: Simultaneously scrolling text vertically in two fields
Hi Dan,
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
then you are too young!urbaud wrote: ↑Mon Sep 25, 2023 4:52 pmHi 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
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
Re: Simultaneously scrolling text vertically in two fields
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).urbaud wrote: ↑Mon Sep 25, 2023 4:52 pmHi 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
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
-
- 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
Young people today...
Craig
Craig
-
- 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
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
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
Re: Simultaneously scrolling text vertically in two fields
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
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
Re: Simultaneously scrolling text vertically 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.
Re: Simultaneously scrolling text vertically in two fields
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
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
-
- 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
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.
I am only 72, and still use HC. Watch the video that Stam posted. This was probably made in 1988 or so.
Craig
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.
I am only 72, and still use HC. Watch the video that Stam posted. This was probably made in 1988 or so.
Craig
Re: Simultaneously scrolling text vertically in two fields
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
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