Page 1 of 1

Managing scroll in grouped groups

Posted: Wed Jan 16, 2019 11:09 pm
by kaveh1000
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

Re: Managing scroll in grouped groups

Posted: Thu Jan 17, 2019 5:27 pm
by bn
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 35 times

Re: Managing scroll in grouped groups

Posted: Thu Jan 17, 2019 6:21 pm
by kaveh1000
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

Re: Managing scroll in grouped groups

Posted: Fri Jan 18, 2019 10:43 am
by kaveh1000
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.

Re: Managing scroll in grouped groups

Posted: Fri Jan 18, 2019 10:49 am
by bn
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

Re: Managing scroll in grouped groups

Posted: Fri Jan 18, 2019 10:53 am
by kaveh1000
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

Re: Managing scroll in grouped groups

Posted: Fri Jan 25, 2019 12:14 am
by kaveh1000
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

Re: Managing scroll in grouped groups

Posted: Fri Jan 25, 2019 12:08 pm
by bn
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