code: public static void addMousePressedHandlers(final Widget widget, final String cssStyleName) {
          widget.sinkEvents(Event.ONMOUSEDOWN);
          widget.sinkEvents(Event.ONMOUSEUP);
          widget.sinkEvents(Event.ONMOUSEOUT);
          widget.sinkEvents(Event.TOUCHEVENTS);
  
          handlerRegistry = new DefaultHandlerRegistry(widget);
          handlerRegistry.registerHandler(widget.addHandler(event -> widget.addStyleName(cssStyleName), MouseDownEvent.getType()));
          handlerRegistry.registerHandler(widget.addHandler(event -> widget.removeStyleName(cssStyleName), MouseUpEvent.getType()));
          handlerRegistry.registerHandler(widget.addHandler(event -> widget.removeStyleName(cssStyleName), MouseOutEvent.getType()));
  
          // Touch Events
          handlerRegistry.registerHandler(widget.addHandler(event -> widget.addStyleName(cssStyleName), TouchStartEvent.getType()));
          handlerRegistry.registerHandler(widget.addHandler(event -> widget.removeStyleName(cssStyleName), TouchEndEvent.getType()));
          handlerRegistry.registerHandler(widget.addHandler(event -> widget.removeStyleName(cssStyleName), TouchCancelEvent.getType()));
      }
docs: Adds a mouse pressed handler to a widget. Adds a CSS style to the widget
  as long as the mouse is pressed (or the user touches the widget on mobile browser).
  
  @param widget       The widget to which the style must be applied for mouse/touch event
  @param cssStyleName CSS style name to be applied