In GWT, how to learn from a SelectionEvent in a tree if the Shift button is pressed

Am I trying in GWT to create a Multiple Choice Tree for nodes and have encountered a problem similar to this Shift Key question in GWT? . When the SelectionEvent element is created from a 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 be applied in this case, since the SelectionHandler class does not inherit from DOMEvent, and then does not have the getNativeEvent () function.

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

Is there a simple solution (or just a solution, even if it is not simple)? Thank.

aem: , FocusPanel keyUp/DownHandler, , , TextArea, "" ... .

+3
2

, Tree, , onBrowseEvent. onSelection , , . JavaScript , . :

public class MyTree extends Tree {
   private Event currentEvent;

   ... constructors...

   // Call this method from within the onSelection method to determine if the shift key
   // was pressed.
   public boolean isShiftPressed() {
      return currentEvent != null ? currentEvent.getShiftKey() : false;
   }

   @Override
   public void onBrowserEvent(Event event) {
     currentEvent = event;
     super.onBrowserEvent(event);
     currentEvent = null;
   }
}
+3

, , :

, , , , Shift? SelectionHandler , .

, , , .

+1

Source: https://habr.com/ru/post/1741267/


All Articles