Пример #1
0
 @Override
 protected void handleComponentInteraction(Slider component, Point location, int button) {
   if (getInteractableComponentRegions(component)[0].contains(location) && button == 0)
     if (Mouse.isButtonDown(button) && !component.isValueChanging())
       component.setValueChanging(true);
     else if (!Mouse.isButtonDown(button) && component.isValueChanging())
       component.setValueChanging(false);
 }
Пример #2
0
 @Override
 protected void handleComponentUpdate(Slider component) {
   if (component.isValueChanging()) {
     if (!Mouse.isButtonDown(0)) {
       component.setValueChanging(false);
       return;
     }
     Point mouse = RenderUtil.calculateMouseLocation();
     Container parent = component.getParent();
     if (parent != null) mouse.translate(-parent.getX(), -parent.getY());
     double percent = (double) (mouse.x - 4) / (double) (component.getWidth() - 6);
     double value =
         component.getMinimumValue()
             + percent * (component.getMaximumValue() - component.getMinimumValue());
     component.setValue(value);
   }
 }