5
« on: December 23, 2013, 02:34:20 PM »
Sorry that I was not clear, looks like I interchanged "list" for "toggle group". Let me try again.
I have a group of UIToggle components each attached to a separate UIWidget. There is also a separate UISprite which is set as the "State Transition Sprite" property of a UIToggle. These are arranged from top to bottom on a window with a UILabel with a description that overlaps the UIWidget areas, but is not parented to them. The UISprite mentioned above is just a little bullet, so that whichever UIWidge the player clicks on, the bullet sprite appears next to the label, showing which item is currently selected.
I believe this is a relatively simple and standard setup, and it works just fine (just to be totally clear, all of the UIToggle components have the same Group ID set).
Here is the issue.
What happens by default, is that each time the window is shown, the bullet appears next to the last item clicked on. The window is not recreated each time, just being hidden and made visible. I understand this behavior and totally expect it. But I want to change it.
The behavior I want, is that each time the window is shown, I want the bullet to appear next to the top label. As I understand it, because the bullet sprite is set as the "State Transition Sprite" of a UIToggle component, its visibility is controlled by that UIToggle's value property.
My code logic was to call a custom function each time the window was opened that looped through all the UIToggle components in the toggle group, and set their value property to "false" except for the top most UIToggle, which would be set to "true". I thought that this would give the desired result of only showing the Bullet sprite associated with the top most UIToggle only.
What is happening however is that when the window is opened for a second time, two bullet sprites are visible, the one associated with the top UIToggle (as desired) and the one which was visible when the window was closed the last time (unexpected). (Note: by "top" I mean Y position on the screen as the UIWidgets the UIToggles are attached to are arranged vertically).
What I hope to find out:
- Should my logic work (and I have a problem elsewhere, perhaps with the notify handler used by the UIToggles in the group)?
- And if not, can you suggest an alternate solution/workaround?
Hopefully this is clearer, and not muddled up worse.
I thank you for your time and help.