Notifications
Clear all
[Closed] Calling dialog from dialog
Jun 16, 2010 9:27 am
I think my previous question post was not clear enough. So I made a sample code.
rollout uiQuestion "uiQuestion" (
button getInput "Click to type your name"
on getInput pressed do (
rollout nameInput "Type Your Name"(
edittext newName ""
button applyIt "OK"
on applyIt pressed do(
getInput.text = newName.text
destroyDialog nameInput
)
)
createDialog nameInput
)
)
createDialog uiQuestion
Basically if an user click the button, a new dialog pops up and gets string input. When the user click OK button, the string that the user type in becomes the button name.
This code works, but I don’t like the nested createDialog. Would there be a better way of doing this?
1 Reply
Jun 16, 2010 9:27 am
I guess it’s ok to call a createDialog in a button method. The thing that doesn’t look clean is to declare the rollout each time you press the button. A cleaner way to write your code could be:
global nameInput
global uiQuestion
rollout nameInput "Type Your Name"
(
edittext newName ""
button applyIt "OK"
on applyIt pressed do
(
uiQuestion.getInput.text = newName.text
destroyDialog nameInput
)
)
rollout uiQuestion "uiQuestion"
(
button getInput "Click to type your name"
on getInput pressed do
(
createDialog nameInput
)
)
createDialog uiQuestion
Anyway, I’d use a rollout floater instead of two differents rollouts, loading the second rollout dynamically; something like:
global nameInput
global uiQuestion
global myRolloutFloater
rollout nameInput "Type Your Name"
(
edittext newName ""
button applyIt "OK"
on applyIt pressed do
(
uiQuestion.getInput.text = newName.text
removerollout nameInput
)
)
rollout uiQuestion "uiQuestion"
(
button getInput "Click to type your name"
on getInput pressed do
(
addrollout nameInput myRolloutFloater
)
)
if myRolloutFloater != undefined do closeRolloutFloater myRolloutFloater
myRolloutFloater = newRolloutFloater "my rollout floater" 200 300
addrollout uiQuestion myRolloutFloater