Firing click event from code in gwt

后端 未结 8 695
甜味超标
甜味超标 2020-12-03 10:27

I have created a custom widget in gwt which extends the composite.I am using focus panel in that.For FocusPanel I added ClickHandler.Then I have added keyboard listner.Now o

8条回答
  •  孤街浪徒
    2020-12-03 10:50

    I have done this code:

    if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER)        {
        myButton.fireEvent( new GwtEvent() {
            @Override
            public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() {
            return ClickEvent.getType();
            }
            @Override
            protected void dispatch(ClickHandler handler) {
                handler.onClick(null);
            }
       });
    }
    

    Of course myButton must be final or public cause you are inside another event handler.

提交回复
热议问题