Пример #1
0
    @Override
    public void onTouchEnd(Event event) {

      valueTooltip.setVisible(false);

      if (SliderView.this.isDisabled()) {
        return;
      }

      if (!continuous) {
        ActionEvent.fire(SliderView.this, SliderView.this);
      }
    }
Пример #2
0
    @Override
    public void onMouseUp(Event event) {

      mouseDown = false;
      DOM.releaseCapture(getElement());

      valueTooltip.setVisible(false);

      if (SliderView.this.isDisabled()) {
        return;
      }

      if (!continuous) {
        ActionEvent.fire(SliderView.this, SliderView.this);
      }
    }
Пример #3
0
    void enable(Event event) {

      if (!mouseDown) {

        double oldValue = getValue();

        calcValue(event);
        DOM.setCapture(getElement());

        mouseDown = true;

        showValueTooltip();

        if (continuous && getValue() != oldValue) {
          ActionEvent.fire(SliderView.this, SliderView.this);
        }
      }
    }
Пример #4
0
    @Override
    public void onMouseMove(Event event) {

      if (SliderView.this.isDisabled()) {
        return;
      }

      if (mouseDown) {

        double oldValue = getValue();

        calcValue(event);
        showValueTooltip();

        if (continuous && getValue() != oldValue) {
          ActionEvent.fire(SliderView.this, SliderView.this);
        }
      }
    }
Пример #5
0
    @Override
    public void onTouchMove(Event event) {

      if (SliderView.this.isDisabled()) {
        return;
      }

      event.preventDefault();

      if (event.getTouches().length() > 0) {

        double oldValue = getValue();

        Touch first = event.getTouches().get(0);
        calcValue(first);

        showValueTooltip();

        if (continuous && oldValue != getValue()) {
          ActionEvent.fire(SliderView.this, SliderView.this);
        }
      }
    }
Пример #6
0
    @Override
    public void onKeyDown(Event event) {

      if (SliderView.this.isDisabled()) {
        return;
      }

      double oldValue = getValue();

      int keyCode = event.getKeyCode();

      if (isVertical()) {

        switch (keyCode) {
          case KeyCodes.KEY_UP:
            {
              double newValue = getValue() + step;
              if (newValue <= getMaxValue()) {
                setValue(newValue);
              }
            }
            break;
          case KeyCodes.KEY_DOWN:
            {
              double newValue = getValue() - step;
              if (newValue >= getMinValue()) {
                setValue(newValue);
              }
            }
            break;
        }
      } else {
        switch (keyCode) {
          case KeyCodes.KEY_RIGHT:
            {
              double newValue = getValue() + step;
              if (newValue <= getMaxValue()) {
                setValue(newValue);
              }
            }
            break;
          case KeyCodes.KEY_LEFT:
            {
              double newValue = getValue() - step;
              if (newValue >= getMinValue()) {
                setValue(newValue);
              }
            }
            break;
        }
      }

      if (oldValue != getValue()) {
        if (showValueTooltip()) {

          if (valueTooltipShowTimer != null) {
            valueTooltipShowTimer.cancel();
          }

          valueTooltipShowTimer =
              new Timer() {
                @Override
                public void run() {
                  valueTooltip.setVisible(false);
                }
              };

          valueTooltipShowTimer.schedule(1000);
        }

        ActionEvent.fire(SliderView.this, SliderView.this);
      }
    }