Applying action to all graphics on card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Applying action to all graphics on card
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Applying action to all graphics on card
Welcome
You can do it in a loop with a list
or for all grcs on cd
Regards
Jean-Marc
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
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
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Applying action to all graphics on card
xfratboy,
regards
Bernd
if you are shure you want to set this for every graphic then you could sayxfratboy wrote:I know there must be a way to get a list of every graphic on a card
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
Bernd
Re: Applying action to all graphics on card
Perfect! Thanks to all.
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Applying action to all graphics on card
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
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
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Applying action to all graphics on card
Bernd,
I am so happy to have be faster
Jean-Marc
I am so happy to have be faster
Jean-Marc
https://alternatic.ch
Re: Applying action to all graphics on card
I have noticed something weird that perhaps the great Bernd or Jean-Marc could answer. Why does this only work once? I have this:
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 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
Code: Select all
on scrollbarLineDec
IncreaseObjectSize
end scrollbarLineDec
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Applying action to all graphics on card
Jean-Marc,
at least I made an honorable second place, not bad
regards
Bernd
at least I made an honorable second place, not bad
regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Applying action to all graphics on card
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
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