Page 1 of 1

Data Grid Form layers and LayoutControl

Posted: Wed Mar 29, 2017 1:28 pm
by ittarter
Hello, everybody.

I have a data grid FORM with multiple objects in group "row template" of the associated data grid template.

Templates start with a graphic "Background" and a text field. To these, I've added a third object (an image), which I've put into the group "row template".

However, there is a problem with layering. Why does the background graphic insist on being in front of my image? Changing the relative layer using the Position tab does NOTHING. Very weird.

Problem 1: The background graphic hides the image of row 1. There is clearly some hidden interaction going on, but it's weird, because I've successfully gotten around this (?) bug before and been able to use images in multi-row data grid forms. But whenever I create a data grid, there's something funky going on with the layer of the background graphic. Some behavior that isn't explicitly spelled out.

Problem 2: only row 1 is displayed at all. For some reason handler LayoutControl is only being called once so only the objects for row 1 are being placed. But why would it do that if I clearly have ten rows of tab delimited text separated by carriage return? (I've checked those invisible chars with Notepad++ and as far as it can tell me, they're all there and in the right place!)

Here's some of the relevant code, just in case I did something silly:

Code: Select all

on FillInData pDataArray
set the text of field "Text" of me to tText
set the filename of img "Icon" of me to tURL
end FillInData

Code: Select all

on LayoutControl pControlRect
   set the width of img "Icon" of me to 100
   set the height of img "Icon" of me to 100
   set the top of fld "Text" of me to item 2 of pControlRect
   set the top of img "Icon" of me to item 2 of pControlRect
   set the top of graphic "Background" of me to item 2 of pControlRect
   set the layer of img "Icon" of me to (1 + graphic "Background" of me) --I've tried it without these lines; no dice
   set the layer of graphic "Background" of me to (1 - img "Icon" of me) --I've tried it without these lines; no dice
   set the rect of graphic "Background" of me to pControlRect
end LayoutControl
Thanks in advance. I've spent all day on this and have had problems in the past but this time have not been able to get my code to magically work...

Ivan

Re: Data Grid Form layers and LayoutControl

Posted: Wed Mar 29, 2017 1:54 pm
by Klaus
Hi Ivan,

of course you need to use the data in pDataArray like this:

Code: Select all

on FillInData pDataArray
  set the text of field "Text" of me to pDataArray["text"] ## tText
  set the filename of img "Icon" of me to pDataArray["url"] ##tURL
end FillInData
Presumed these (text, url) are the names of the key in the array.
Or are tText and tUrl global or local variables? Probably not.

If you already set up the correct layers in the "row template" then you should NOT set it again in the "LayoutControl" handler.
Same for the height/width of your image. But make sure the image has its "lockloc" set to true.

Besides this, what math operation is this supposed to be: (1 + graphic "Background" of me)? 8)
You surely mean (1 + the layer of grc "Background" of me), however this is not neccessary at all.

All in all, it looks like you don't need the "LayoutControl" handler at all, if the "row template" has been set up correctly,
since obviously there is nothing "dynamic" going on. Know what I mean?

That is only neccessary if you need to adjust the layout of your form depending on its content, which is not the case here.


Best

Klaus

Re: Data Grid Form layers and LayoutControl

Posted: Wed Mar 29, 2017 2:28 pm
by ittarter
Hi Klaus

Thanks for your reply and specifically for helping clarify that LayoutControl is only necessary for dynamic layouts.

I'm not using an actual array for my dgText, just tab-delimited text, so I believe that the data grid identifies item 1 with the array key "label 1".

I'm still very confused about why the background graphic refuses to cooperate, even if I am just trying to change its layer in the object tab "Position".

However, closing and opening my stack seems to have fixed some of the issues. Strange. I also took your advice and removed the bulk of my LayoutControl code, so that helped too :)

Re: Data Grid Form layers and LayoutControl

Posted: Wed Mar 29, 2017 2:40 pm
by Klaus
Grrrreat! :D

Re: Data Grid Form layers and LayoutControl

Posted: Wed Mar 29, 2017 5:24 pm
by jacque
I'm still very confused about why the background graphic refuses to cooperate, even if I am just trying to change its layer in the object tab "Position".
There's a known layering bug in LC 8.1.3 that will be fixed in 8.1.4. Right now you can only set a control to layer 1.

Re: Data Grid Form layers and LayoutControl

Posted: Wed Mar 29, 2017 9:13 pm
by Klaus
jacque wrote:There's a known layering bug in LC 8.1.3 that will be fixed in 8.1.4. Right now you can only set a control to layer 1.
Oh, did not know this! Did not much relayering recently... 8)

But to be honest, this is a real shame for the mothership! :(