SAPUI5 - Unable to intercept click event on element - sapui5

I'm facing a problem with getting control over 'click' event on sap.viz.ui5.types.legend.Common which extends Element not Control. The task is to manage clicks on the ellipsis ("...") in Legend which set as non-scrollable.The main problem, as far as I understand, is that the Legend is not a control and it's kinda tricky to catch onclick event for it.

Related

Implementing "onclickout" with GWT

I need a way of capturing onclick event when a user clicks out of a FocusPanel(in the form of a dialog box). I need to warn the user to save their work before clicking outside thus losing the panel. I know how to do it in JavaScript but it I am stuck with GWT. Any assistance will be appreciated.
Every click event provides coordinates of a click. Check that these coordinates are outside of your popup panel.
Alternatively, make your PopupPanel modal, so that users can exit it only by clicking on UI elements that you provide, for example, submit and cancel/close buttons.

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.

Windows Forms Error Provider does not display in custom tab control

I'm trying to build a Wizard framework in Windows Forms. I've managed to glean a lot of useful tips from this and other sites which have gotten me very close to success. However, I'm having a problem with displaying an ErrorProvider on any tab page other than the first page of the wizard.
My Wizard control is a UserControl. It contains a custom tab control that I've derived from TabControl so that I can hide tabs and ignore attempts to navigate between tabs using keypresses, along with the usual collection of Back/Next/Finish/Cancel buttons at the bottom of the control.
I've used reflection to allow me to raise the validation events on a particular TabPage that belongs to the Wizard Control when I hit the Next button. (I don't want to validate the whole TabControl, only the currently active page.) When I do this, I see in the debugger that my Validating routine for the controls on the current tab page is correctly called and I see that I've called the ErrorProvider that I've attached to the particular control (a TextBox in this case) with a valid error message. I set Cancel to true for the CancelEventArgs in the validating routine and that's picked up by the code that uses the reflection mechanism so that I see that I've failed and don't change tabs. And I set the focus successfully to the control that failed validation.
So all that appears to be working just fine.
Unfortunately, I don't see the ErrorProvider's cheery blinking icon unless I'm on the first tab page. For all of the other tab pages, there's no message visible at all.
I'm baffled. Any thoughts? I can provide code snippets, if helpful.
Thanks!
I assume that in your case the button that moves to the next step of the wizard is placed outside (below) the TabControl
I noticed that the icon is displayed correctly if I pressed the button without releasing the mouse button. It seems that the button outside the container gets focused event though a validation error has occurred (normally you would not be able to leave the active control).
I worked around this issue by registering an event handler for the buttons MouseUp event to "refocus" the TabControl:
private void cmdOK_MouseUp(object sender, MouseEventArgs e)
{
tabControl1.Focus();
}
Note: you also need to set your forms ActiveControl property the one of the controls that failed validation.

GWT cells selection

I wish to make a drag and select application in GWT where I wish to have cell table or grid of say 20*100 columns*rows. I want to add a event such that I can drag something like a rectangle with my mouse and all the cells in that region get selected or I can fire an event for each cell and assign each of them a same ID. The main idea behind the thing is to perform a selection by dragging and then grouping all selected cells as one, something like Excel sheet selection. Can any one help me out in this?
I have once implemented GWT widget allowing to "select" some rectangular region of a table. Basically the idea was to subclass a Grid or FlexTable and do all the logic in various mouse event handlers (mouse down, mouse up, mouse out, mouse over).
The only minor hack I had to introduce was a method for getting the cell for any mouse event. There is a method HTMLTable#getCellForEvent that works for a click event, but when I looked into implementation of this method, I saw that it could actually work for any event, so I just implemented my own method for getting cell for any mouse event based on mentioned implementation.
Maybe it would be also possible to achieve this using HTMLTable#getEventTargetCell

How to avoid closing Popup

I have an Popup(not modal window) which shows textbox, when I start typing in the textbox I need to open another popup which show listbox,when I select any item from list box the popup disappears as well the previous popup also disappears how can I avoid closing of the very first popup on close of 2nd popup.
Use a standard "bandpopup" component - in this case you wouldn't even have a second popup to manage. Other thing which comes to my mind is add onClose event listener or event handler - whichever you prefer - and stop event propagation with Event.stop(caughtEvent). It will effectively prevent propagation of OnClose event and your first popup wouldn't be closed.