Example #1
0
    @Override
    public void onBrowserEvent(Event event) {
      Element td = getEventTargetCell(event);

      if (td == null) {
        return;
      }
      Element tr = DOM.getParent(td);

      String index = tr.getAttribute("item-index");
      if (index == null || "".equals(index)) {
        return;
      }

      switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEOVER:
          onRowHovered(tr);
          break;

        case Event.ONCLICK:
          onRowClicked(tr);
          event.preventDefault();
          event.stopPropagation();
          break;
      }
    }
Example #2
0
 private void choiceDestroyLinkClick(Event e) {
   e.preventDefault();
   if (!isDisabled) {
     pendingDestroyClick = true;
     Element target = e.getEventTarget().cast();
     choiceDestroy($(target));
   } else {
     e.stopPropagation();
   }
 }
Example #3
0
 private void processHandleEvent(Event event) {
   switch (DOM.eventGetType(event)) {
     case Event.ONMOUSEDOWN:
     case Event.ONTOUCHSTART:
       if (!disabled && !readonly) {
         focus();
         feedbackPopup.show();
         dragging = true;
         DOM.setElementProperty(
             handle, "className", CLASSNAME + "-handle " + CLASSNAME + "-handle-active");
         DOM.setCapture(getElement());
         DOM.eventPreventDefault(event); // prevent selecting text
         DOM.eventCancelBubble(event, true);
         event.stopPropagation();
         VConsole.log("Slider move start");
       }
       break;
     case Event.ONMOUSEMOVE:
     case Event.ONTOUCHMOVE:
       if (dragging) {
         VConsole.log("Slider move");
         setValueByEvent(event, false);
         updateFeedbackPosition();
         event.stopPropagation();
       }
       break;
     case Event.ONTOUCHEND:
       feedbackPopup.hide();
     case Event.ONMOUSEUP:
       // feedbackPopup.hide();
       VConsole.log("Slider move end");
       dragging = false;
       DOM.setElementProperty(handle, "className", CLASSNAME + "-handle");
       DOM.releaseCapture(getElement());
       setValueByEvent(event, true);
       event.stopPropagation();
       break;
     default:
       break;
   }
 }
Example #4
0
  private void processHandleEvent(Event event) {
    switch (DOM.eventGetType(event)) {
      case Event.ONMOUSEDOWN:
      case Event.ONTOUCHSTART:
        if (!disabled && !readonly) {
          focus();
          feedbackPopup.show();
          dragging = true;
          handle.setClassName(getStylePrimaryName() + "-handle");
          handle.addClassName(getStylePrimaryName() + "-handle-active");

          DOM.setCapture(getElement());
          DOM.eventPreventDefault(event); // prevent selecting text
          DOM.eventCancelBubble(event, true);
          event.stopPropagation();
        }
        break;
      case Event.ONMOUSEMOVE:
      case Event.ONTOUCHMOVE:
        if (dragging) {
          setValueByEvent(event, false);
          updateFeedbackPosition();
          event.stopPropagation();
        }
        break;
      case Event.ONTOUCHEND:
        feedbackPopup.hide();
      case Event.ONMOUSEUP:
        // feedbackPopup.hide();
        dragging = false;
        handle.setClassName(getStylePrimaryName() + "-handle");
        DOM.releaseCapture(getElement());
        setValueByEvent(event, true);
        event.stopPropagation();
        break;
      default:
        break;
    }
  }
Example #5
0
  private void onTouchStart(Event event) {

    onHoldPressDownStyle(); // Show style change

    // Stop the event from bubbling up
    event.stopPropagation();

    // Only handle if we have exactly one touch
    if (event.getTargetTouches().length() == 1) {
      Touch start = event.getTargetTouches().get(0);
      this.touchId = start.getIdentifier();
      this.touchMoved = false;
    }
  }
  @Override
  public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    switch (DOM.eventGetType(event)) {
      case Event.ONCONTEXTMENU:
        EventTarget target = event.getEventTarget();

        Element svg = this.getElement().getElementsByTagName("svg").getItem(0);

        if (target.equals(svg)) {
          m_client.getContextMenu().showAt(this, event.getClientX(), event.getClientY());
          event.preventDefault();
          event.stopPropagation();
        }
        break;

      case Event.ONMOUSEDOWN:
        break;

      case Event.ONMOUSEWHEEL:
        double delta = event.getMouseWheelVelocityY() / 30.0;
        double oldScale = m_scale;
        final double newScale = oldScale + delta;
        final int clientX = event.getClientX();
        final int clientY = event.getClientY();
        // broken now need to fix it
        //    	    Command cmd = new Command() {
        //
        //                public void execute() {
        //                    m_client.updateVariable(m_paintableId, "mapScale", newScale, false);
        //                    m_client.updateVariable(m_paintableId, "clientX", clientX, false);
        //                    m_client.updateVariable(m_paintableId, "clientY", clientY, false);
        //
        //                    m_client.sendPendingVariableChanges();
        //                }
        //            };
        //
        //            if(BrowserInfo.get().isWebkit()) {
        //                Scheduler.get().scheduleDeferred(cmd);
        //            }else {
        //                cmd.execute();
        //            }

        break;
    }
  }
Example #7
0
  private void onClick(Event event) {
    event.stopPropagation();
    event.preventDefault();

    if (touchHandled) {
      // if the touch is already handled, we are on a device that supports
      // touch (so you aren't in the desktop browser)

      touchHandled = false; // reset for next press
      clickHandled = true; // ignore future ClickEvents
    } else if (!clickHandled) {
      // Press not handled yet
      fireFastClickEvent();
    }

    super.onBrowserEvent(event);
  }
Example #8
0
  @Override
  public void onBrowserEvent(Event event) {
    if (disabled || readonly) {
      return;
    }
    final Element targ = DOM.eventGetTarget(event);

    if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {
      processMouseWheelEvent(event);
    } else if (dragging || targ == handle) {
      processHandleEvent(event);
    } else if (targ == smaller) {
      decreaseValue(true);
    } else if (targ == bigger) {
      increaseValue(true);
    } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
      processBaseEvent(event);
    } else if ((BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS)
        || (!BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN)) {

      if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), event.getShiftKey())) {

        feedbackPopup.show();

        delayedValueUpdater.trigger();

        DOM.eventPreventDefault(event);
        DOM.eventCancelBubble(event, true);
      }
    } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONFOCUS) {
      feedbackPopup.show();
    } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONBLUR) {
      feedbackPopup.hide();
    } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
      feedbackPopup.show();
      processBaseEvent(event);
    }
    if (Util.isTouchEvent(event)) {
      event.preventDefault(); // avoid simulated events
      event.stopPropagation();
    }
    if (client != null) {
      client.handleTooltipEvent(event, this);
    }
  }
Example #9
0
 /** Dispatch an event in this element but changing the type, it's useful for special events. */
 public void dispatchEvent(Event event, String eventName) {
   int etype = Event.getTypeInt(eventName);
   Object[] handlerData = $(element).data(EVENT_DATA);
   for (int i = 0, l = elementEvents.length(); i < l; i++) {
     BindFunction listener = elementEvents.get(i);
     String namespace = JsUtils.prop(event, "namespace");
     boolean matchEV =
         listener != null && (listener.hasEventType(etype) || listener.isTypeOf(eventName));
     boolean matchNS =
         matchEV && (isNullOrEmpty(namespace) || listener.nameSpace.equals(namespace));
     if (matchEV && matchNS) {
       if (!listener.fire(event, handlerData)) {
         event.stopPropagation();
         event.preventDefault();
       }
     }
   }
 }
Example #10
0
 @Override
 public void onBrowserEvent(Event event) {
   switch (DOM.eventGetType(event)) {
     case Event.ONCLICK:
       {
         // tabs can be closed by (a) middle mouse (anywhere), or (b)
         // left click on close element
         if (event.getButton() == Event.BUTTON_MIDDLE
             || (Element.as(event.getEventTarget()) == closeElement_
                 && event.getButton() == Event.BUTTON_LEFT)) {
           closeHandler_.onTabClose();
           event.stopPropagation();
           event.preventDefault();
         }
         break;
       }
   }
   super.onBrowserEvent(event);
 }
Example #11
0
  @Override
  public void onBrowserEvent(Event event) {

    if (!this.isEnabled()) {
      event.stopPropagation();
      return;
    }
    switch (DOM.eventGetType(event)) {
      case Event.ONTOUCHSTART:
        {
          onTouchStart(event);
          event.stopPropagation();
          break;
        }
      case Event.ONTOUCHEND:
        {
          onTouchEnd(event);
          event.stopPropagation();
          break;
        }
      case Event.ONTOUCHMOVE:
        {
          onTouchMove(event);
          event.stopPropagation();
          break;
        }
      case Event.ONMOUSEUP:
        {
          Log.debug("touch up");
          // because Event.ONCLICK always came twice on desktop browsers oO
          onClick(event);
          event.stopPropagation();
          break;
        }
      case Event.ONMOUSEDOWN:
        {
          event.stopPropagation();
          break;
        }
      default:
        {
          // Let parent handle event if not one of the above (?)
          try {
            super.onBrowserEvent(event);
          } catch (Throwable t) {
            Log.debug(DOM.eventGetType(event) + "event failed");
          }
        }
    }
  }
  @Override
  public void onBrowserEvent(Event event) {
    GWT.log("slider mouse event: " + DOM.eventGetTypeString(event));
    if (DOM.eventGetType(event) == Event.ONCONTEXTMENU) {

      event.stopPropagation();
      event.preventDefault();

      int x = event.getClientX();
      int y = event.getClientY();
      NodeList<Node> children = getChildren().get(0).getElement().getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        Node child = children.getItem(i);
        Element widget = (Element) child;
        String id = widget.getId();
        GWT.log("checking " + id + " to see if its the rightclicked element");
        int left = widget.getAbsoluteLeft();
        int width = widget.getOffsetWidth();
        int top = widget.getAbsoluteTop();
        int height = widget.getOffsetHeight();

        if (left < x && left + width > x && top < y && top + height > y) {

          this.clickedElement = DOM.getElementById(id);

          GWT.log(editor.getElement().getId() + " context menu for " + id);
          GWT.log("positioning context menu at " + event.getClientX() + "x" + event.getClientY());
          contextMenu.show(event.getClientX(), event.getClientY(), menu);
          break;
        }
      }

    } else if (DOM.eventGetType(event) == Event.ONCLICK) {
      ContextMenu.hide();
    }
    super.onBrowserEvent(event);
  }
Example #13
0
  private boolean containerMouseDown(Event e) {
    if (isDisabled) {
      return true;
    }
    Element target = e.getEventTarget().cast();
    GQuery $e = $(target);

    boolean targetCloseLink = $e.hasClass(css.searchChoiceClose());

    if (!resultsShowing) {
      e.stopPropagation();
    }

    if (!pendingDestroyClick && !targetCloseLink) {
      if (!activeField) {
        if (isMultiple) {
          searchField.val("");
        }
        $(document).click(clickTestAction);
        resultsShow();
      } else if (!isMultiple
          && !$e.isEmpty()
          && ($e.get(0) == selectedItem.get(0)
              || $e.parents("a." + css.chznSingle()).length() > 0)) {
        e.preventDefault();
        resultsToggle();
      }

      activateField(e);

    } else {
      pendingDestroyClick = false;
    }

    return false;
  }
Example #14
0
  @Override
  public void onBrowserEvent(Event event) {

    int eventType = event.getTypeInt();
    switch (eventType) {
      case Event.ONMOUSEDOWN:
        {
          event.preventDefault();
          event.stopPropagation();
        }
        break;
      case Event.ONMOUSEOVER:
        {
          if (isEnabled()) {
            if (menu != null) {
              menu.setActiveMenuItem(this);
            }
          }
        }
        break;
      case Event.ONMOUSEOUT:
        {
          if (menu != null) {
            if (subMenu != null) {
              if (!subMenuVisible) {
                menu.setActiveMenuItem(null);
              }
            } else {
              menu.setActiveMenuItem(null);
            }
          }
        }
        break;
      case Event.ONCLICK:
        {
          handleClick();
        }
        break;
      case Event.ONTOUCHSTART:
        {
          event.stopPropagation();

          if (isEnabled()) {
            if (menu != null) {
              menu.setActiveMenuItem(this);
            }
          }
        }
        break;
      case Event.ONTOUCHEND:
        {
          if (menu != null) {
            if (subMenu != null) {
              if (!subMenuVisible) {
                menu.setActiveMenuItem(null);
              }
            } else {
              menu.setActiveMenuItem(null);
            }
          }
        }
        break;
      default:
        {
          super.onBrowserEvent(event);
        }
    }
  }
Example #15
0
  @Override
  public void onBrowserEvent(final Event event) {
    boolean bubble = true;

    final int type = event.getTypeInt();

    final Element target = DOM.eventGetTarget(event);

    if (resizing || resizeBox == target) {
      onResizeEvent(event);
      bubble = false;
    } else if (isClosable() && target == closeBox) {
      if (type == Event.ONCLICK) {
        onCloseClick();
      }
      bubble = false;
    } else if (target == maximizeRestoreBox) {
      // handled in connector
      if (type != Event.ONCLICK) {
        bubble = false;
      }
    } else if (header.isOrHasChild(target) && !dragging) {
      // dblclick handled in connector
      if (type != Event.ONDBLCLICK && draggable) {
        if (type == Event.ONMOUSEDOWN) {
          headerDragPending = event;
        } else if (type == Event.ONMOUSEMOVE && headerDragPending != null) {
          // ie won't work unless this is set here
          dragging = true;
          onDragEvent(headerDragPending);
          onDragEvent(event);
          headerDragPending = null;
        } else {
          headerDragPending = null;
        }
        bubble = false;
      }
    } else if (dragging || !contents.isOrHasChild(target)) {
      onDragEvent(event);
      bubble = false;
    } else if (type == Event.ONCLICK) {
      // clicked inside window, ensure to be on top
      if (!isActive()) {
        bringToFront();
      }
    }

    /*
     * If clicking on other than the content, move focus to the window.
     * After that this windows e.g. gets all keyboard shortcuts.
     */
    if (type == Event.ONMOUSEDOWN
        && !contentPanel.getElement().isOrHasChild(target)
        && target != closeBox
        && target != maximizeRestoreBox) {
      contentPanel.focus();
    }

    if (!bubble) {
      event.stopPropagation();
    } else {
      // Super.onBrowserEvent takes care of Handlers added by the
      // ClickEventHandler
      super.onBrowserEvent(event);
    }
  }