Data Grid breaks resize handler

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
golife
Posts: 103
Joined: Fri Apr 02, 2010 12:10 pm

Data Grid breaks resize handler

Post by golife » Sun Mar 14, 2021 11:21 pm

I have a problem with my resize handler that is placed in the stack script.

I am using a data grid and I need to resize the height depending on the resizing of the stack by the user. All works well until the height of the Data Grid is recalculated. From this moment on, the resizing of breaks visibly. The Data Grid is not placed on top of the bottom "footergroup". The group "footergroup" also suddenly does not resize with this last part of the script.

Has anybody see such problem with the Data Grid? Or is there any solution? My "workaround" here could only be to prohibit resizing of the stack which I do not really want to do.

Or am I blind and do not see what is wrong?

Here is the script fragment:

Code: Select all

on resizeStack w,h
    // "DGList" is the Data Grid group
    // The group "DGList" (Data Grid) is formatted in "table" style
    local tDGHeight
    
    --- Headergroup
   if there is a group "headergroup" then
      set the width of group "headergroup" to w
      set the top of group "headergroup" to 0
      set the left of group "headergroup" to 0
      --- 
      set the width of graphic "headerpane" to w
      set the left of graphic "headerpane" to 0
      set the top of graphic "headerpane" to 0
   end if
   --- Footergroup
   if there is a group "footergroup" then
      set the width of group "footergroup" to w
      set the left of group "footergroup" to 0
      set the bottom of group "footergroup" to h
      ---
      set the width of graphic "footerpane" to w
      set the left of graphic "footerpane" to 0
      set the bottom of graphic "footerpane" to h
   end if
   
   // ERROR Data Grid group "dgList" breaking the handler
   if there is a group "dgList" then
      set the left of group "dgList" to 0
      
      -- h is the height of the stack
      put h - the height of group "footergroup" - the height of group "headergroup" - 60 into tDGHeight
      
      //  ERROR: Script breaks. DG group resized arbitrary, nothing works correctly:
      set the height of group "dgList" to tDGHeight
      set the bottom of group "dgList" to the top of group "footergroup"
   end if

end resizeStack

cpuandnet
Posts: 32
Joined: Thu Jan 17, 2019 6:43 am

Re: Data Grid breaks resize handler

Post by cpuandnet » Mon Mar 15, 2021 7:38 pm

You need to pass on the "resizeStack" message. Try adding pass "resizeStack" to the bottom of the script.

Code: Select all

on resizeStack w, h
   ...
   
   pass "resizeStack"
end resizeStack
I hope this helps.

golife
Posts: 103
Joined: Fri Apr 02, 2010 12:10 pm

Re: Data Grid breaks resize handler

Post by golife » Tue Mar 16, 2021 12:57 am

@by cpuandnet

Thank you very much for the answer. I thought "Oh My ..." ))). Unfortunately, it did not make a difference.
The script works for all other controls (passing or not passing resize) only if I do not resize the height of the datagrid group.

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Re: Data Grid breaks resize handler

Post by elanorb » Tue Mar 16, 2021 10:00 am

Hi

Is your DataGrid a table or a form? If it is a form I wonder if something in the row script is affecting things. You could try locking messages around where you set the height of the DataGrid, this is likely to break the display in the DataGrid but it might give you a clue about what is happening.

Code: Select all

lock messages
set the height of group "dgList" to tDGHeight
unlock messages
Elanor
Elanor Buchanan
Software Developer
LiveCode

golife
Posts: 103
Joined: Fri Apr 02, 2010 12:10 pm

Re: Data Grid breaks resize handler

Post by golife » Tue Mar 16, 2021 12:32 pm

@elanorb

Dear Elanor, also thank you for your comment.

No, it is not working. I tried lockscreen before, but anyway, the resizeStack handler already locks the screen inherently.

So far, I tried:

- wait 0 with messages
- wait 10 with messages
- lock screen/unlock screen
- pass resizeStack

I come to the conclusion that it must have something to do with the datagrid itself which in this case is formatted in "table" style.

There is a second datagrid on this card (of type "form") and it seems to interfere here, or both somehow are affecting each-other.
When I use one datagrid on one card all works well, but with these two datagrids not so much.

I completely removed the first datagrid group "dgList" and recrated it. Now, strangely enough, the content area of the second datagrid moves with the resizeStack handler even though nothing of that group has been defined to be dependent on anything. Or somehow, the template group has switched to point to the other datagrid. I do not understand what is happening here.

When I create two datagrids on a fresh card, all works well again.

My impression is that I am somehow on to a bug. Maybe it is just this specific configuration that created the anomaly.
If I find some rule here, I will post it.

Thanks to all

golife
Posts: 103
Joined: Fri Apr 02, 2010 12:10 pm

Re: Data Grid breaks resize handler

Post by golife » Tue Mar 16, 2021 7:11 pm

No, the problem reappeared even with renaming the datagrid group. First it worked, now it does not. :x

I found the problem.

My second datagrid that I placed onto the card had the name "dgList". When removing it, all seemed ok, but there was something strange going on within the original group "dgDetail".

After having a coffee, it appeared to my mind that possibly there is a subgroup within the datagrid called "dgList". And actually, that was the case.

The owner of group "dgList" is group "dgListMask"
The owner of group "dgListMask" is my group "dgDetail"

So, we have a name conflict.

Solution: Do not name your own datagrid groups using "dg" as the prefix. There might already be such group inside the datagrid group. Or check before you use a name if it does not already exist.


Unfortunately NOT even though it fixed the problem that parts inside of the other group were moving with the resizing.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”