Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

SmartGWT LGPL v5.0 ListGrid addKeyPressHandler

$
0
0
Hello,

1. SmartClient Version: v10.0p_2014-11-18/LGPL Development Only (built 2014-11-18)

2. browser(s) and version(s) involved:Firefox 39.0

I want to add keyboard key pressed handler to a ListGrid. I tried with this code:
Code:

        ListGrid.addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                                  deleteRecord(getSelectedRecord());
            }
        });

but doesn't work only when the columns header is selected. It looks like the ListGrid doesn't receive the focus. I would like to be able to select a row and to press Delete keyboard button and the handler to be invoked.
I tried also with this code:
Code:

this.addDrawHandler(new DrawHandler() {

            @Override
            public void onDraw(DrawEvent event) {
                CommonListGrid.this.getBody().addKeyPressHandler(new KeyPressHandler() {

                    @Override
                    public void onKeyPress(KeyPressEvent event) {
                            deleteRecord(getSelectedRecord());
                    }
                });
             
                if (CommonListGrid.this.getBody() != null) {
                    CommonListGrid.this.getBody().addFocusChangedHandler(new FocusChangedHandler() {
                        @Override
                        public void onFocusChanged(FocusChangedEvent event) {
                            SC.logWarn("Focus changed to:" + event.getHasFocus());
                        }
                    });
                }
            }
        });

but the handlers are never invoked.
So what I am doing wrong here? There is a possibility to select a ListGrid row and to have focus in order to receive Delete keyboard pressed event?

Thank you

Viewing all articles
Browse latest Browse all 4756

Trending Articles