src/main/java/com/spinyowl/legui/component/misc/listener/scrollbar/ScrollBarMouseClickEventListener.java
@Override
  public void process(MouseClickEvent event) {
    ScrollBar scrollBar = (ScrollBar) event.getTargetComponent();
    boolean released = event.getAction() != MouseClickEvent.MouseClickAction.PRESS;
    if (!event.getButton().equals(MOUSE_BUTTON_LEFT)) {
      return;
    }

    Vector2f pos = scrollBar.getAbsolutePosition();
    Vector2f cursorPosition = Mouse.getCursorPosition();

    float visibleAmount = scrollBar.getVisibleAmount();
    boolean vertical = Orientation.VERTICAL.equals(scrollBar.getOrientation());

    Vector2f guiSize = scrollBar.getSize();
    float arrowSize = scrollBar.isArrowsEnabled() ? scrollBar.getArrowSize() : 0;
    float scrollBarSize = (vertical ? guiSize.y : guiSize.x) - 2 * arrowSize;
    float maxValue = scrollBar.getMaxValue();
    float minValue = scrollBar.getMinValue();
    float valueRange = maxValue - minValue;

    if (valueRange - visibleAmount < 0.001f) {
      return;
    }

    float barSize = scrollBarSize * visibleAmount / valueRange;
    if (barSize < ScrollBar.MIN_SCROLL_SIZE) {
      barSize = ScrollBar.MIN_SCROLL_SIZE;
    }

    float curValue = scrollBar.getCurValue();
    float scrollPosAccordingToScrollBounds = (scrollBarSize - barSize) * curValue / valueRange;

    float left;
    float curPos;
    float newVal;
    if (vertical) {
      left = pos.y + scrollPosAccordingToScrollBounds + arrowSize;
      curPos = cursorPosition.y;
    } else {
      left = pos.x + scrollPosAccordingToScrollBounds + arrowSize;
      curPos = cursorPosition.x;
    }
    if (curPos < left) {
      newVal = curValue - 0.5f * visibleAmount * valueRange / (valueRange - visibleAmount);
      if (!released) {
        updateViewport(event, scrollBar, maxValue, minValue, newVal);
      }
      scrollBar.setScrolling(false);
    } else if (curPos > left + barSize) {
      newVal = curValue + 0.5f * visibleAmount * valueRange / (valueRange - visibleAmount);
      if (!released) {
        updateViewport(event, scrollBar, maxValue, minValue, newVal);
      }
      scrollBar.setScrolling(false);
    } else {
      scrollBar.setScrolling(!released);
    }
  }
/**
   * Used to handle {@link MouseClickEvent}
   *
   * @param event event to handle.
   */
Used to handle  MouseClickEvent
@param event event to handle.
Used to handle MouseClickEvent @param event event to handle .
@Override
  public void process(MouseClickEvent event) {
    ScrollBar scrollBar = (ScrollBar) event.getTargetComponent();
    boolean released = event.getAction() != MouseClickEvent.MouseClickAction.PRESS;
    if (!event.getButton().equals(MOUSE_BUTTON_LEFT)) {
      return;
    }
    Vector2f pos = scrollBar.getAbsolutePosition();
    Vector2f cursorPosition = Mouse.getCursorPosition();
    float visibleAmount = scrollBar.getVisibleAmount();
    boolean vertical = Orientation.VERTICAL.equals(scrollBar.getOrientation());
    Vector2f guiSize = scrollBar.getSize();
    float arrowSize = scrollBar.isArrowsEnabled() ? scrollBar.getArrowSize() : 0;
    float scrollBarSize = (vertical ? guiSize.y : guiSize.x) - 2 * arrowSize;
    float maxValue = scrollBar.getMaxValue();
    float minValue = scrollBar.getMinValue();
    float valueRange = maxValue - minValue;
    if (valueRange - visibleAmount < 0.001f) {
      return;
    }
    float barSize = scrollBarSize * visibleAmount / valueRange;
    if (barSize < ScrollBar.MIN_SCROLL_SIZE) {
      barSize = ScrollBar.MIN_SCROLL_SIZE;
    }
    float curValue = scrollBar.getCurValue();
    float scrollPosAccordingToScrollBounds = (scrollBarSize - barSize) * curValue / valueRange;
    float left;
    float curPos;
    float newVal;
    if (vertical) {
      left = pos.y + scrollPosAccordingToScrollBounds + arrowSize;
      curPos = cursorPosition.y;
    } else {
      left = pos.x + scrollPosAccordingToScrollBounds + arrowSize;
      curPos = cursorPosition.x;
    }
    if (curPos < left) {
      newVal = curValue - 0.5f * visibleAmount * valueRange / (valueRange - visibleAmount);
      if (!released) {
        updateViewport(event, scrollBar, maxValue, minValue, newVal);
      }
      scrollBar.setScrolling(false);
    } else if (curPos > left + barSize) {
      newVal = curValue + 0.5f * visibleAmount * valueRange / (valueRange - visibleAmount);
      if (!released) {
        updateViewport(event, scrollBar, maxValue, minValue, newVal);
      }
      scrollBar.setScrolling(false);
    } else {
      scrollBar.setScrolling(!released);
    }
  }
@ Override public void process ( MouseClickEvent event ) { ScrollBar scrollBar = ( ScrollBar ) event . getTargetComponent ( ) ; boolean released = event . getAction ( ) != MouseClickEvent . MouseClickAction . PRESS ; if ( ! event . getButton ( ) . equals ( MOUSE_BUTTON_LEFT ) ) { return ; } Vector2f pos = scrollBar . getAbsolutePosition ( ) ; Vector2f cursorPosition = Mouse . getCursorPosition ( ) ; float visibleAmount = scrollBar . getVisibleAmount ( ) ; boolean vertical = Orientation . VERTICAL . equals ( scrollBar . getOrientation ( ) ) ; Vector2f guiSize = scrollBar . getSize ( ) ; float arrowSize = scrollBar . isArrowsEnabled ( ) ? scrollBar . getArrowSize ( ) : 0 ; float scrollBarSize = ( vertical ? guiSize . y : guiSize . x ) - 2 * arrowSize ; float maxValue = scrollBar . getMaxValue ( ) ; float minValue = scrollBar . getMinValue ( ) ; float valueRange = maxValue - minValue ; if ( valueRange - visibleAmount < 0.001f ) { return ; } float barSize = scrollBarSize * visibleAmount / valueRange ; if ( barSize < ScrollBar . MIN_SCROLL_SIZE ) { barSize = ScrollBar . MIN_SCROLL_SIZE ; } float curValue = scrollBar . getCurValue ( ) ; float scrollPosAccordingToScrollBounds = ( scrollBarSize - barSize ) * curValue / valueRange ; float left ; float curPos ; float newVal ; if ( vertical ) { left = pos . y + scrollPosAccordingToScrollBounds + arrowSize ; curPos = cursorPosition . y ; } else { left = pos . x + scrollPosAccordingToScrollBounds + arrowSize ; curPos = cursorPosition . x ; } if ( curPos < left ) { newVal = curValue - 0.5f * visibleAmount * valueRange / ( valueRange - visibleAmount ) ; if ( ! released ) { updateViewport ( event , scrollBar , maxValue , minValue , newVal ) ; } scrollBar . setScrolling ( false ) ; } else if ( curPos > left + barSize ) { newVal = curValue + 0.5f * visibleAmount * valueRange / ( valueRange - visibleAmount ) ; if ( ! released ) { updateViewport ( event , scrollBar , maxValue , minValue , newVal ) ; } scrollBar . setScrolling ( false ) ; } else { scrollBar . setScrolling ( ! released ) ; } }
Used to handle {@link MouseClickEvent}
 @param event event to handle.
Used to handle { @link MouseClickEvent } @param event event to handle .