tags:

views:

90

answers:

2

Hi,

For my project when a button is clicked, the click event should then wait and listen to the next two clicks on different widgets and then connect them so as to form relationship between them.

Right now i an trying to use FocusListener without success. Any suggestion will be of great help.

Thank you.

+3  A: 

I would think you'd just want an ClickListener for each object. Handle "enabling" the other two objects in the first object's click event, then when those two objects are clicked on, invoke the method to form the relationship. You don't want to wait in the first object's event handler.

Moishe
A: 

First use always the Handlers instead of the Listeners the latter are deprecated.

I'm not sure if you mean by wait to actual halt in the method, but that's never a good idea in JavaScript, because JavaScript is not multi-threaded.

As a idea for your question.The way I would approach it is, for each click mark the click event in a central class with some logic. All widgets that have click events call to this class to mark the click and the widget that clicked. Now each time a click from a widget is handled, the logic in the class calculates if a relationship must be formed, or if the state must be reset. For example. If the button was clicked it is marked, second if next two clicks are marked, at the last click the logic in the class now determines the relationships must be formed. By storing the widgets that clicked in the class when the click event is marked you can connect those widgets. I hope it makes sense, it's rather abstract.

Hilbrand