Hi LiveCoders!
I am creating an app to demonstrate how Grade 2 Braille is written. Each character pattern is composed of 6 dots. I have created a group called Braille Dot containing 6 oval graphics. I have added a script to the group so that a call to setPattern(pInteger) will set the background colour of the appropriate dots to black to create one of the 64 possible patterns. So far so good.
I now want to show a group of symbols, to create a word. For example, the word "teaching" would be written in 4 patterns as "t-ea-ch-ing", and "learner" would be 5 patterns as "l-e-ar-n-er".
I had hoped that I would be able to add my Braille Dot group to the card multiple times, and to call setPattern() on each group independently, so that each instance of the group would show a different pattern. As far as I can tell, I will have to create many distinct groups, each containing 6 distinct oval graphics. This seems like unnecessary duplication.
I understand that I can set the `behavior`of each group to point at one unique control, so I do not need to duplicate the script.
Is there a similar technique that would allow me to display many instances of the same control on the same card, each with a different set of properties (similar to setting `sharedText` property for a field to false)?
Thanks in advance,
James
Reusing a group on the same card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Reusing a group on the same card
Hi.
If I understand your problem, you will want to store and hide each of the 64 unique patterns. If you name your graphics "t", "ea", "ch", and "ing", (and so on), then to assemble the word, you can clone each one in turn, setting their respective locs as required, (pseudo):
Or do I have this totally wrong?
Craig Newman
If I understand your problem, you will want to store and hide each of the 64 unique patterns. If you name your graphics "t", "ea", "ch", and "ing", (and so on), then to assemble the word, you can clone each one in turn, setting their respective locs as required, (pseudo):
Code: Select all
get "t,ea,ch,ing"
repeat for each item tPattern in it
clone grc tPattern
make that last grc visible, since it derives from a hidden control
set the loc of grc tPattern to the right spot for that graphic
end repeat
Craig Newman
Re: Reusing a group on the same card
Hi Craig,
Thanks for your reply.
In fact, a Braille Dot group will work in two different ways:
* The user can touch each of the dots in any pattern, to toggle it on or off, to create a new pattern.
* When a word is displayed, the various pattern will be sent to a set of Braille Dot groups, to spell out the word automatically.
I plan to have a set of groups permanently on the screen, in fixed positions. Their content will vary according to the user's interactions.
Because the user can change the pattern of dots, it makes more sense to have an "editable" pattern rather than a set of predefined images.
If I understand your answer, it is this: I can use `clone` to create multiple instances of a group on a card.
Am I right? Does this have to be done using code, or is there a way to create a clone using the GUI?
James
Thanks for your reply.
In fact, a Braille Dot group will work in two different ways:
* The user can touch each of the dots in any pattern, to toggle it on or off, to create a new pattern.
* When a word is displayed, the various pattern will be sent to a set of Braille Dot groups, to spell out the word automatically.
I plan to have a set of groups permanently on the screen, in fixed positions. Their content will vary according to the user's interactions.
Because the user can change the pattern of dots, it makes more sense to have an "editable" pattern rather than a set of predefined images.
If I understand your answer, it is this: I can use `clone` to create multiple instances of a group on a card.
Am I right? Does this have to be done using code, or is there a way to create a clone using the GUI?
James
Re: Reusing a group on the same card
You can duplicate a control when in edit mode, either via selecting the control and "duplicate" (cmd-D), or by option-dragging a pre-selected control. I am not sure this is what you want to do, though.
Or you can create an environment that creates a duplicate when, say, the user option-drags in run mode. But this requires coding, and would be merely a UI feature.
Craig
Or you can create an environment that creates a duplicate when, say, the user option-drags in run mode. But this requires coding, and would be merely a UI feature.
Craig
Re: Reusing a group on the same card
Thanks Craig!