Listener function for gwt widgets - gwt

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.

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.

Related

How do I pass variables through a button click event handler and make changes to the button within the subroutine it's been passed to in visual basic?

I'm trying to make a minesweeper game using visual basic forms. I have made the tiles by making each one a separate button. I have made an array of Boolean values to decide which buttons have mines. I am stuck because I can't figure out how to pass variables through the event handler. I also don't know how to make changes to the button within the subroutine that is called with the button click event handler.
I would appreciate any help anyone can offer.
Thanks a lot!

Creating a set of buttons with oncick events on them

I have an array of objects in my game, and I want to create buttons in the UI, based on object count in array. In menu construction script, array is scanned for objects, and for each of them button is created, and labeled by object name.
Now I want to do onclick event for these buttons which will display info about respective object in the UI. So I need to somehow create a onclick event for each of appearing buttons, or create universal onclick event for this group of buttons, which will read object name from button and search for that in the array. Is it possible to create events for objects which are going to appear during game? Please suggest.
Workaround - by onclick event get buttons array and find which is hovered by mouse ATM
you could make a widget object containig the button with the onclick event, then in the contruction script you create the widgets.
Here you can find some documentation for widgets:
https://docs.unrealengine.com/en-US/Engine/UMG/UserGuide/WidgetBlueprints/index.html
https://docs.unrealengine.com/en-US/Engine/UMG/UserGuide/CreatingWidgets/index.html

Common Event Listener for multiple instances of custom element

I am creating a dropdown-multi-select custom element.
When user clicks outside the dropdown, I would like to close the dropdown, therefore I am attaching an event listener to the window to detect outside-click.
My Problem is when multiple instance of this component is created, there will be multiple event listeners doing the same job.
I intend to put this component in every row of a table with 1000 rows
I would like to know
Is there a better way to do it.
Having 1000s of event listener, should I be concerned about it
Even if you have 1000s of drop-down custom element, only one is active at a given time.
Therefore you should attach on window the event listener for the active (and expended) drop-down list...
...and detach it when the drop-down list has collapsed.

How to unregister GWT eventbus handlers in a Popup/DialogBox?

I have a dialog box, which contains a button and a TabLayoutPanel. The button is outside the TabLayoutPanel. Tab contents are separate custom widgets.
The problem: I want to respond to clicks on the button by performing an action inside one of the tab content widgets.
I tried using the GWT EventBus this way:
fire an event upon button click
add handler for this event inside the tab
But here's the problem: if I close/open the tab multiple times, the event handler will be registered again. And when the button is clicked, the event handler will start multiple times (for every handler registration/however many times the tab was opened).
Since my dialog box doesn't have an activity/place, I cannot use GWT's Activity.start(... EventBus eventBus) for automatic activity deregistration.
A possible solution is to manually remember registered HandlerRegistration(s) and .removeHandler() them when I navigate away from the tab. But this is a rather ugly solution.
Question: Is there a way to unregister events in a dialog box without remembering them?
It's hard to give a concrete answer without code, but I'd do it like this:
Add ClickHandler to the button when the Popup/Dialog gets opened.
If this button is clicked, check which tab is the active one and call a specific method on the widget in that tab.
getSelectedIndex() and getWidget(index) should be the methods on the TabLayoutPanel to use to determine which widget is the active one.
Unregister the clickhandler after the Popup/Dialog got closed.
This way, you have only one Handler to remove what should be the normal way, e.g. with the onClose() event of the DialogBox.

How we Fire more than one event on same control in MVVM (WPF)

I am creating WPF application using MVVM pattern. I want to fire more than one event on same control. For example: If i have placed one button. i want to fire Mouse_Up event as well as Loaded event on same button. Please Help me thanks in advance.