Skip to Content
0
Former Member
Nov 04, 2011 at 01:03 PM

Synchronous User Interaction in Instance-Method

43 Views

Hey Guys!

I got a problem getting information by user synchronous.

To make it understandable I abstracted the problem a little:

I have a class 'player'. It has an attribute 'name' and a method 'get_name'.

In get_name i want to ask the actual user for his/her name. A dialogue should open with a text-field and an ok-button.

(Solvable with DD_Documents -> no Problem as far).

But then I want to save the given value in text-field in the 'name'-variable.

This is a problem: Not because of getting the data out of the input field but because of the flow-control!

I know I could write a method in the same class to react to the interaction and save the variable. But if I want to use one or more players in a program, it does not wait until the variable is set to go on.

I do not want to go on with the code in the method as long as the user didn't press ok.

Can I wait for an event in a method?

Hope you get my problem!

Thank you for your help!