In GWT, how to known from a SelectionEvent in a Tree if the Shift button is pressed

Posted by Vinze on Stack Overflow See other posts from Stack Overflow or by Vinze
Published on 2010-04-15T12:11:04Z Indexed on 2010/04/15 12:13 UTC
Read the original article Hit count: 254

Filed under:
|

Hi, I try in GWT to create a Tree with multiple selection for the nodes and ran into a problem similar to this question http://stackoverflow.com/questions/1411752/shift-key-in-gwt. When a selectionEvent is raised from the Tree, I would like to know if the Shift key is pressed or not.

SelectionHandler<TreeItem> getSelectionHandler() {
    return new SelectionHandler<TreeItem>(){
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            // is shift key pressed ?
        }
    };
}

The solution in the question above cannot apply in this case as the SelectionHandler class does not inherit from DOMEvent and then does not have a getNativeEvent() function.

I tried a dirty solution by adding keyDownEventHandler and keyUpEventHandler to the Tree with a boolean flag but the handlers are only called when the focus is on the tree so this doesn't work.

Is there a simple solution (or just a solution even if it's not simple) ? Thanks.

© Stack Overflow or respective owner

Related posts about gwt

Related posts about event-handling