GWT FocusPanel, tab and focus handlers

I am implementing my own widget that extends Compositeand implements Focusableand HasFocusHandlers.

The widget contains two widgets in the panel that I bring to FocusPanel, which I use to initialize the widget. My constructor looks something like this:

public CustomBox() {
    panel = new VerticalPanel();
    ...
    panel.add(caption);
    panel.add(icon);
    ...
    focusPanel = new FocusPanel(panel);
    initWidget(focusPanel);
}

I delegate the implementation Focusableand HasFocusHandlersthe focus panel, for example:

@Override
public void setFocus(boolean focused) {
    focusPanel.setFocus(focused);
}

@Override
public void setTabIndex(int index) {
    focusPanel.setTabIndex(index);        
}

@Override
public HandlerRegistration addFocusHandler(FocusHandler handler) {
    return focusPanel.addFocusHandler(handler);
}   

And after that I can use setFocus(true)to set the focus in any of my objects and setTabIndex()to set the tab index. The Tab key also works as expected, but my problem is that I cannot handle focus events, since the method of onFocus()handlers added with help addFocusHandler()is never called.

, , , :focus CSS.

?

+3
1

. GWT , FocusPanel DIV, . jQuery:

, . , (<input> , <select> , ..) (< a href > ). , , tabindex . , Tab .

, , - HTML//dom . , caption, icon a FocusPanel? , .

0

Source: https://habr.com/ru/post/1752063/


All Articles