Managing scroll in grouped groups

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Managing scroll in grouped groups

Post by kaveh1000 » Wed Jan 16, 2019 11:09 pm

Hi all

I have a number of identical groups that are then grouped together, in a scrolling group. I want to be able to have some control over the scroll of the outer group, specifically, tabbing into a field in one of the groups should scroll to bring that group and its field into view.

I can think of long winded ways of doing this, but any hint would be welcome. Thanks.

Please see attached minimal example.

Kaveh
Attachments
scrolling group.zip
(1.11 KiB) Downloaded 191 times
Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3990
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Managing scroll in grouped groups

Post by bn » Thu Jan 17, 2019 5:27 pm

Hi Kaveh,

here is a version of your example stack that can be scrolled with a scroll wheel. To make this work I added a graphic at the lowest layer of the main group. That way rawKeyDown is trapped by the main group. That graphic is resized when you resize the group.

Furthermore it scrolls the subgroups into view if you tab from field to field. I disabled traversalOn for the buttons because otherwise you would have to tab twice to get to the next field.

Note that if you have a focusable control on the card that will be focused when tabbing from the last field. Which is normal behavior.

All handlers are in the script of the main group. See also comments in the script of the main group.

Kind regards
Bernd

KavehGroupsBN_2.livecode.zip
modified Script
(2.45 KiB) Downloaded 189 times

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Managing scroll in grouped groups

Post by kaveh1000 » Thu Jan 17, 2019 6:21 pm

That's astonishing, Berndt. You have just ruined my weekend!! I will be studying this intensely and will report back any comments.

Thank you so much for taking the time to do this.

Regards
Kaveh
Kaveh

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Managing scroll in grouped groups

Post by kaveh1000 » Fri Jan 18, 2019 10:43 am

Bernd, I am still going thro these handlers to fully understand. I modified a little bit (e.g. I have several groups, so "the owner" became "the owner of the owner of the owner", etc, but it works amazingly well.

One thing I found is that when I have more than one field in a group, then when I focus in another field in the same group sets the scroll of the parent group to zero. Off-hand, is your script designed to handle multiple fields in a group? I have a feeling it is my stack that is messing that up.
Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3990
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Managing scroll in grouped groups

Post by bn » Fri Jan 18, 2019 10:49 am

kaveh1000 wrote:
Fri Jan 18, 2019 10:43 am
One thing I found is that when I have more than one field in a group, then when I focus in another field in the same group sets the scroll of the parent group to zero. Off-hand, is your script designed to handle multiple fields in a group?
I did not test that. Best would be if you could post a sample of your new setup and I will look into that.

Kind regards
Bernd

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Managing scroll in grouped groups

Post by kaveh1000 » Fri Jan 18, 2019 10:53 am

thanks Berndt. Let's see if I can fix it as it is a good exercise. If I get stuck I will come back.

And an extra thank you for your color lightening stack that I found and found useful :-)

viewtopic.php?t=11100
Kaveh

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Managing scroll in grouped groups

Post by kaveh1000 » Fri Jan 25, 2019 12:14 am

Hi Bernd

While working on implementing your superb code, I notice that you have not called resizeControl to resize the graphic. Am I right that it should be called at the start of OpenField?

Kaveh
Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3990
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Managing scroll in grouped groups

Post by bn » Fri Jan 25, 2019 12:08 pm

Hi Kaveh,

resizeControl is only necesseary when the rect of the "main" group changes. Then it resizes the "back" graphic to fit the "sub" groups so that scrollWheel messages can be trapped by the "main" group.
"resizeControl" is a system message that is sent to a group when it is resized.

On "openField" the main group does not change size, so no "resizeControl" is necessary.


Kind regards
Bernd

Post Reply

Return to “Talking LiveCode”