Exemplo n.º 1
0
  protected void itemMouseEvent(MouseEvent e, Point tempPt) {
    mouseInside = false;
    visibleMouseEvent(e, tempPt);
    if (isOpen()) {
      for (int i = zSortedItems.size() - 1; i >= 0; i--) {
        MenuItem item = (MenuItem) zSortedItems.get(i);
        if (e.isConsumed()) continue;
        item.itemMouseEvent(e, tempPt);
        if (item.mouseInside) mouseInside = true;
      }
    }
    if (mouseInside && getZ() == 0) {
      setZ(1);
      if (parent != null) parent.needsZSort = true;
    } else if (!mouseInside && getZ() == 1) {
      setZ(0);
      if (parent != null) parent.needsZSort = true;
    }

    /*
     * If the mouse is inside but we're disabled, we want to not show the hand cursor.
     */
    if (mouseInside && !isEnabled()) {
      menu.setCursor(Cursor.DEFAULT_CURSOR);
    }
  }
Exemplo n.º 2
0
  protected void visibleMouseEvent(MouseEvent e, Point tempPt) {
    super.visibleMouseEvent(e, tempPt);
    if (!isEnabled()) return;

    float curInterval = increment;

    if (e.isControlDown() != controlDown) {
      controlDown = e.isControlDown();
      startY = tempPt.y;
      startVal = getValue();
    }
    if (e.isControlDown()) {
      curInterval /= 5f;
    }

    if (mouseInside) {
      menu.setCursor(Cursor.N_RESIZE_CURSOR);
    }
    switch (e.getID()) {
      case (MouseEvent.MOUSE_PRESSED):
        if (mouseInside) {
          if (e.getClickCount() > 1) {
            setValue(defaultValue);
          }
          startY = tempPt.y;
          startVal = getValue();
          scrolling = true;
          nearestMenu.context.focus().setModalFocus(this.menu);
        }
        break;
      case (MouseEvent.MOUSE_DRAGGED):
        if (scrolling) {
          float dy = startY - tempPt.y;
          float dVal = dy * curInterval * scrollSpeed;
          value = startVal + dVal;
          setValue(value);
          e.consume();
        }
        break;
      case (MouseEvent.MOUSE_RELEASED):
        if (scrolling) {
          e.consume();
          scrolling = false;
          nearestMenu.context.focus().removeFromFocus(this.menu);
        }
        break;
    }
  }