2017년 5월 22일 월요일

How do you pass a user interface component as an argument (AI2)?


I need to be able to manipulate the attributes of a an interface object from within a procedure, based on which component called the procedure.  A simplified example;  I have several buttons each of which calls a procedure named "changeStuff"'. When "changeStuff" is called, it changes the text and textColor of the calling button.  I can not figure out how to abstract and pass the calling object.   The only way I see to accomplish is through a lengthy IF/ELSE IF statement within the procedure (which negates it's purpose) and repeat each block code explicitly for each possible button.  Not efficient and I know there is a way, but my OOP is lacking.  any thoughts????

by the by.. I see that most UI components have a 'get' block option with just the component name therein.  What is this for?  I can find no documentation on it.

--
You can do this using the 'Any' blocks at the bottom of the Blocks Editor palette,
passing them the component blocks (last in the palette) of each and any
component you want to handle.

The component blocks can be gathered into lists at Screen1.Initialize
time (not before) or referenced by name if unique.

Here's a link to documentation of a test app using this tevhnique
on balls ...

Angry Balls V3 Documentation

--

댓글 없음:

댓글 쓰기