How to add clickhandler on ImageCell in GWT CellTable?

前端 未结 8 1324
再見小時候
再見小時候 2021-02-06 04:01

I have tried this but didn\'t work

Column imageColumn = new Column(new ImageCell()) {
       @Override
             


        
8条回答
  •  孤城傲影
    2021-02-06 04:35

    You can extend ImageCell class and override 2 it's methods - getConsumedEvents and onBrowserEvent. Example:

        private class MyImageCell extends ImageCell{
    
        @Override
        public Set getConsumedEvents() {
            Set consumedEvents = new HashSet();
            consumedEvents.add("dblclick");
            return consumedEvents;
        }
    
        @Override
        public void onBrowserEvent(Context context, Element parent,
                String value, NativeEvent event,
                ValueUpdater valueUpdater) {
                switch (DOM.eventGetType((Event)event)) {
                case Event.ONDBLCLICK:
                    // TODO
                    break;
    
                default:
                    break;
                }
        }
    
    }
    

提交回复
热议问题