Page 1 of 1

Looping through all elements of same type

Posted: Sat Oct 27, 2012 9:49 am
by doobox
The incorrect code below should say what i am looking to do. Though i guess i am way of the mark with my repeat statement :

Code: Select all

   repeat for each field of this card // this line is incorrect..?
      if the short name of me is "label"
      set the textsize of me to the textsize of me + 10
   end repeat

Re: Looping through all elements of same type

Posted: Sat Oct 27, 2012 9:57 am
by doobox
Managed to dig some similar code out of a runrev video, and modify the code to work for me :

Code: Select all

   repeat with x=1 to the number of fields of this card
       if the short name of field x is "label" then
         set the textsize of field x to the textsize of field x + 10
      end if
   end repeat

Re: Looping through all elements of same type

Posted: Sat Oct 27, 2012 10:20 am
by doobox
One of the issues a saw when returning to livecode dev, was the lack of support for iPhone 5 in MobGUI.

You can use the custom size in MobGUI for iphone 5, but one of the main issues a see with this, is that label texts are not scaled when seen on iPhone 5.
This overcomes that.
If you place this on every card, all the button labels and the nav label is scaled up as it is for retina.
I may not have the number exactly right here but that can be played with.

Code: Select all

on openCard
   put iphoneDeviceResolution() into tScreenResolution
   put item 2 of tScreenResolution into tScreenheight
   wait 10 ticks with messages // seems to only work with this waiting time
   if tScreenheight is 1136 then
      repeat with x=1 to the number of fields of this card
         if the short name of field x is "label" then
            set the textsize of field x to the textsize of field x + 10
            set the height of field x to the height of field x + 10
         end if
      end repeat
   end if
end openCard