Groups, layers & scrolling

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
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Groups, layers & scrolling

Post by cusingerBUSCw5N » Mon Nov 20, 2017 4:54 pm

I have an image and several fields that go over the image. I have grouped them with other objects on the card and I need a scroller for that card because it does not fit on the screen.

Initially, the image and the objects are invisible. They are activated in two stages - first the image, and then the fields that go over the image.

The fields that go over the image invariably end up behind the image. I tried setting the using the property inspector, but they seem to change...i.e. I set it for 100, and it becomes 15... or variations like that.

So then I tried changing them in the code right before the scroller was created using this code:

Code: Select all

set the relayerGroupedControls to true
 put the layer of group "group_deals4" into twhat
  set the layer of field "deals1"  to twhat-1
  set the layer of field "deals2"  to twhat-2
set the layer of field "deals3"  to twhat-3
   set the layer of field "deals4"  to twhat-4
The great news is that the fields show up.... the UN-great news is that when you scroll it, everything except those 4 lines scroll - those lines were kicked out of group_deals4

So...I don't know how groups and scrollers and layers are supposed to work. Why do the layers change? Why can't I set the order and have it stay the same.... and why when I change the layer in script, does it affect who is in the group?

Thanks

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

Re: Groups, layers & scrolling

Post by dunbarx » Mon Nov 20, 2017 6:08 pm

One quick point, If you make, say, four buttons on a new card, the layer of the first button will be "1". If you then say:

Code: Select all

set the layer of btn 1 to 1000
the layer of that button will only rise to 4, the number of controls. LC will not set a fifth (or 1000th) layer for a control on a card where there are only four controls.

It is an easy way to bring a control to the top of the heap, however. Just set the layer to a googol.

Craig Newman

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Groups, layers & scrolling

Post by cusingerBUSCw5N » Mon Nov 20, 2017 11:22 pm

OK. I understand that, and I have been setting the layer of these stupid fields for several days..but they change.

so, I put a button on the card to get the layer of the field and the layer of the image.

On my computer, my button says that the layer of the field is 112 and the image is 123. This would indicate that the field wouldn't show - because it's behind the image. However, IT DOES SHOW. When I edit the group, it says for the same items - that the image is 24 and the field is 34 - so the image shows - which it does.
So what set of layers is it using?

When I do a test on my android, the button says that the field is 113 and the image is 124...which is basically the same as on my computer, but on the test THE FIELD DOESN'T SHOW. I don't know how to test the underlying numbers (24/34) on my computer.

No wonder I'm going crazy.

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

Re: Groups, layers & scrolling

Post by dunbarx » Tue Nov 21, 2017 12:07 am

Hi.

I do not program for mobile, but is it possible other graphic properties, like the blendLevel, might be allowing a lower layer control to appear behind an upper layer one?

Craig

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

Re: Groups, layers & scrolling

Post by dunbarx » Tue Nov 21, 2017 12:14 am

Hmmm.

On a new card make three buttons. Name the first one of them "b1" and the second "b2".

In the script of the third btn:

Code: Select all

on mouseup
   answer the layer of btn "b1" && the layer of btn "b2"
end mouseup
You will see "1 2"

Now group btns "b1" and "b2". Click on that third button again. Grouping does its own layering stuff when invoked, since you are creating yet another control and including other (maybe lower) controls within it.

Is this possibly the issue?

Craig

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Groups, layers & scrolling

Post by cusingerBUSCw5N » Tue Nov 21, 2017 12:43 am

Yes.... that is probably what is happening...but my scroller is dropping items from the old group and only scrolling some of them. If it scrolls properly, then the items are behind the picture and can't be seen.

I will make a simple stack and attach it later today.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Groups, layers & scrolling

Post by jacque » Tue Nov 21, 2017 4:41 pm

dunbarx wrote:
Mon Nov 20, 2017 6:08 pm

It is an easy way to bring a control to the top of the heap, however. Just set the layer to a googol.
Or just use the constant "top":

set the layer of control x to top
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Groups, layers & scrolling

Post by cusingerBUSCw5N » Tue Nov 21, 2017 6:27 pm

Here is my stripped stack. I tried uploading the file, but it claims it's too big (although it's only 783,058) - so I have uploaded it on my server : http://www.toolsforbusiness.info/test_l ... lling2.zip

Once unzipped, Click that you don't want to add an image, select a color and submit. It will load properly and you should see the text on top of the image. Scroll it. Everything will scroll except the text boxes on the image. Before you try it, read the Please Note message below. You will want to move fields "line1" through "line4" into the group before you begin.

PLEASE NOTE: When you look at the Project Browser, the sample I zipped shows that the line1 through line 4 are NOT in the group. They were in the group - but were kicked out somehow... That's why they aren't scrolling with the rest of the group. I believe that it is caused because of the code in the button - but if I don't do that code, then line 1 through 4 are kicked behind the image and won't show.

Any help in figuring out how to get both the text boxes (line 1 through line 4) on top AND the text boxes to be part of the scroller are appreciated.

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

Re: Groups, layers & scrolling

Post by dunbarx » Tue Nov 21, 2017 6:41 pm

I have not looked at your stack.

But, again, just quickly, you do know that if the "relayerGroupedControls" property is set, then it is possible to kick a control out of a group by setting its layer higher or lower than the range of controls within that group. Is that possibly what has "orphaned" those two misbehaving fields?

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Groups, layers & scrolling

Post by jacque » Tue Nov 21, 2017 8:14 pm

I haven't looked at the stack either but I was going to mention what Craig pointed out -- relayerGroupedControls allows controls to be moved outside the group.

There may be some confusion about the layering numbers. Higher numbers are drawn above controls with lower numbers. Layer 1 is underneath everything else. By setting the layers to the group's number minus some amount, you are essentially moving it out of the group. To do what you want, get the ID of the image. Then repeat for as many times as you have fields to move:

Code: Select all

put the layer of img <x> into tImgLayer
repeat for each item i in "deals1,deals2,deals3,deals4"
    set the layer of field i to tImgLayer + 1
end repeat
This will stack each field on top of the image, inside the group.

Regarding background edit mode: When this is active, LC moves all the group controls to a temporary card and assigns temporary layer numbers. You can ignore these, except to reference their relative positions. When background editing is turned off, the controls are moved back to the real card and their (potentially altered) layering is recalculated.

BTW, you shouldn't need to code the layering. It can all be done in the property inspector and will be persistent. The only reason to script the layers would be if you are dynamically altering the layers based on current card conditions or user actions. For simple display, one setup during development should be enough.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Groups, layers & scrolling

Post by cusingerBUSCw5N » Tue Nov 21, 2017 9:51 pm

so it worked! eliminated all layering, reset everything and it's good. Thanks

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”