Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT PushButton ClickHandler needs mouse movement after click

Tags:

java

gwt

I’m building 2 columns of buttons, and after upgrading to GWT 2.4.0 I’m having problems with my click event.

On a pc after clicking the button, you have to move the mouse position to get the event to fire. On an iPad, the button has to be pressed a second time.

int rows = (int) Math.ceil( (double)alphaLettersList.size() / 2);

Grid toolbarGrid = new Grid(rows, 2);

int numRows = toolbarGrid.getRowCount();
int numColumns = toolbarGrid.getColumnCount();

int i = 0;
for (int col = 0; col < numColumns; col++) {
    for (int row = 0; row < numRows; row++) {
        if (i < alphaLettersList.size()) {
            final String letter = (String) alphaLettersList.get(i).toUpperCase();

            PushButton letterButton = new PushButton();
            letterButton.setHTML("<div class='googleLetterBtn'>"+letter+"</div>");

            letterButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    LocalSurveyManager2.getInstance().getArticlesForLetter(letter,     RoomPanelArticleForLetterListener.getInstance());                            
            }
            });                 

            toolbarGrid.setWidget(row, col, letterButton);
        }
        i++;
    }

}
like image 986
jhaley Avatar asked Feb 12 '26 08:02

jhaley


1 Answers

I solved this by using the MouseDownHandler and the TouchStartHandler instead of the ClickHandler.

like image 114
jhaley Avatar answered Feb 14 '26 22:02

jhaley