Page 1 of 1

Applying action to all graphics on card

Posted: Mon Mar 29, 2010 6:20 am
by xfratboy
Yet another newbie question here. I've been playing around with graphic objects and I would like to figure out an easy way to set properties of every graphic on my card (e.g. height, width, backgroundcolor). For example, let's say I have 2 ovals, two polygons, and two rectangles, on my card. How could I apply the same action to every graphic on the card without having to write the same command for each object, e.g.
set the height of graphic oval1 to the height of graphic oval1 +10
set the height of graphic oval2 to the height of graphic oval2 +10
set the height of graphic poly1 to the height of graphic poly1 +10
set the height of graphic poly2 to the height of graphic poly2 +10
set the height of graphic rect1 to the height of graphic rect1 +10
set the height of graphic rect2 to to the height of graphic rect2 +10

I know there must be a way to get a list of every graphic on a card then loop through that list, but I don't know what I'm doing. Any pointers would be greatly appreciated.

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 7:49 am
by jmburnod
Welcome

You can do it in a loop with a list

Code: Select all

on ResizeSomeG
   put "oval1,oval2,poly1,poly2,rect1,rect2" into LesG
   repeat with i = 1 to the num of items of LesG
      put item i of LesG into UnG
      set the height of grc UnG to (the height of grc UnG) +10
   end repeat
end ResizeSomeG
or for all grcs on cd

Code: Select all

on ResizeAllG
   repeat with i = 1 to the num of grcs
      set the height of grc i to (the height of grc i) +10
   end repeat
end ResizeAllG
Regards
Jean-Marc

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 9:47 am
by bn
xfratboy,
xfratboy wrote:I know there must be a way to get a list of every graphic on a card
if you are shure you want to set this for every graphic then you could say

Code: Select all

repeat with i = 1 to the number of graphics
   set the width of graphic i to the width of graphic i + 10
end repeat
regards
Bernd

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 1:16 pm
by xfratboy
Perfect! Thanks to all.

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 9:39 pm
by bn
xfratboy,
all the thanks go to Jean-Marc. When I posted I somehow did not realize he had also posted the handler for every graphic on the card
regards
Bernd

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 9:45 pm
by jmburnod
Bernd,

I am so happy to have be faster :D

Jean-Marc

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 9:52 pm
by xfratboy
I have noticed something weird that perhaps the great Bernd or Jean-Marc could answer. Why does this only work once? I have this:

Code: Select all

on IncreaseObjectSize
 put "ObjBall,ObjOval,ObjLine,ObjDiamond,ObjSquare" into myObjectList
   repeat with i = 1 to the number of items of myObjectList
      put item i of myObjectList into UnG
      if the height of graphic UnG on stack "untitled 3" >400 then next repeat
      set the height of graphic UnG on stack "untitled 3" to the height of graphic UnG + 5
      set the width of graphic UnG on stack "untitled 3" to the width of graphic UnG +5
      end repeat
end IncreaseObjectSize
The first time it runs it seems to work. But clicking a second time does nothing. I'm executing the handler from a scrollbar button like this:

Code: Select all

on scrollbarLineDec
      IncreaseObjectSize
end scrollbarLineDec

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 10:00 pm
by bn
Jean-Marc,

at least I made an honorable second place, not bad :)

regards
Bernd

Re: Applying action to all graphics on card

Posted: Mon Mar 29, 2010 11:23 pm
by bn
xfratBoy,

did you set the lineInc (depending on your preferences it could be called "on arrow click") in the inspector -> basic propterties -> Scroll distance? for me it defaulted to 0, when I set it to 1 or any other value it works for me.

regards
Bernd