is there any way to get an event when I switch between widget on a Stackpanel? something like an openhandler for stackpanel. I have to know the index of an open Widget on a Stackpanel.
Using StackLayoutPanel: http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/StackLayoutPanel.html
Use the addSelectionHandler()
method. To get the selected widget, you can use getVisibleIndex()
or getVisibleWidget()
.
myStackPanel.addSelectionHandler(new SelectionHandler<Integer>() {
@Override
public void onSelection(SelectionEvent<Integer> event) {
int selectedWidgetIndex = stackPanel.getVisibleIndex());
//Do stuff with the selectedWidgetIndex
}
});
EDIT: This is using StackLayoutPanel, the OP uses StackPanel. The difference between them is that StackPanel is for quirks mode and StackLayout Panel for Standards Mode. I would StackLayoutPanel or any Layout related widget as new GWT widgets uses them, like the new DataGrid.