2

I made a stack that displays lines of text that change their width when the stack is resized. The Category columns is changing its position on resizing but the check box does not.

What am I missing in the code? What changes have to be made?

See the code in the stack that can be downloaded here: https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form-variable%20line%20height%2Bcheckbox.zip

Thanks in advance.

keram

mark
  • 222
  • 1
  • 9

2 Answers2

0

Because the DataGrid doesn't have this feature. If you would use the Geometry manager, the GM propeties are not copied from the checkbox in the template to the checkboxes in the actual DG. So, the GM won't work. Perhaps you could write a script of your own that sets the right of all checkboxes to a position relative to the width of the card:

on resizeStack
  lock screen
  repeat with x = 1 to number of buttons
    if the style of btn x is "checkbox" then
      set the right of btn x to the width of this cd - 100
    end if
  end repeat
  unlock screen
end resizeStack

Unfortunately, this doesn't work with the datagrid either, because the DG also does some (or a lot) resizing of its own.

It would be much easier to create your own.

Mark
  • 2,380
  • 11
  • 29
  • 49
  • Thanks Mark, Well, creating any script on my own is not easy, since I'm a complete beginner. So far I've been able to check other stack examples and parts of code and somehow put them together... I need to learn a lot more. – mark Dec 12 '13 at 00:45
0

If I understand what you are trying to achieve here then in your LayoutControl handler make the following change:

 --   put the rect of btn "btnCheck" of me into theFieldRect
 --   put item 3 of pControlRect - 5 into item 3 of theFieldRect
 --   set the rect of btn "btnCheck" of me to theFieldRect
 set the left of btn "btnCheck" of me to the right of fld "cat" of me

However I think the resizing of the Cat field is wrong too. Try something like:

on LayoutControl pControlRect
   set the right of btn "btnCheck" of me to item 3 of pControlRect-4
   set the right of fld "Cat" of me to the left of btn "btnCheck" of me
   get the rect of fld "Line" of me
   put the left of fld "Cat" of me into item 3 of it
   set the rect of fld "Line" of me to it
   put the formattedHeight of fld "Line" of me + item 2 of it into item 4 of it
   set the rect of fld "Line" of me to it
   put item 4 of it into item 4 of pControlRect
   set the rect of graphic "Background" of me to pControlRect
end LayoutControl

To edit the LayoutControl script you need to open the datagrid property inspector and click on the Row Behavior... button. This will present the script editor for the behavior of the row template.

Monte Goulding
  • 2,380
  • 1
  • 21
  • 25
  • Hi Monte, Thanks for your reply. The upper part of the code works OK. The lower 7 lines I experimented with by putting them in the card code or stack code but they do not work at all. Here is the link to the stack: https://www.dropbox.com/s/ug694xdr2rjvfka/Data%20grid%20Form-variable%20line%20height%2Bcheckbox-OK.zip – mark Dec 12 '13 at 11:01
  • I have added a note about how to edit the LayoutControl script – Monte Goulding Dec 12 '13 at 11:04
  • Thanks again, Monte. Now I did put these 7 lines into Row Behavior script but then nothing shows up. – mark Dec 12 '13 at 11:32
  • Ah... sorry I had a slight issue with one line. I've fixed it above and completed the whole handler so you can just copy and paste ;-) – Monte Goulding Dec 12 '13 at 18:59
  • It works much better now. And it looks simpler than the initial code I had. Thanks! – mark Dec 13 '13 at 00:26
  • I'd like to Vote Up your response but I cannot do it :-( – mark Dec 13 '13 at 01:35
  • If you're happy with my answer you can accept it as correct by clicking the checkbox. It appears somebody on SO likes to down vote my posts for no apparent reason and with no explanation... not sure why that is... – Monte Goulding Dec 13 '13 at 01:54
  • Now both 1-line view and Complete line view are working OK. But the **strange** thing is that **Behavior Scripts for both views are the same**!?? - I don't understand why? The stack can be downloaded from here: http://stackoverflow.com/questions/20542113/toggle-1-line-complete-line-view-view-one-complete-line-in-separate-card – mark Dec 13 '13 at 03:17