Search in sources :

Example 1 with TextArea

use of com.spinyowl.legui.component.TextArea in project legui by SpinyOwl.

the class TextAreaViewportScrollListener method process.

/**
 * Used to handle specific event.
 *
 * @param event event to handle.
 */
@Override
public void process(ScrollEvent event) {
    Vector2f cursorPosition = Mouse.getCursorPosition();
    Component targetComponent = event.getTargetComponent();
    if (hasViewportsInAboveLayersUnderCursor(targetComponent, cursorPosition)) {
        return;
    }
    ArrayList<Component> targetList = new ArrayList<>();
    SehUtil.recursiveTargetComponentListSearch(Mouse.getCursorPosition(), event.getTargetComponent(), targetList);
    for (Component component : targetList) {
        if ((component instanceof TextArea) || (component instanceof ScrollablePanel)) {
            return;
        }
    }
    TextArea textArea = (TextArea) event.getTargetComponent().getParent();
    textArea.resizeTextAreaField();
    if (Math.abs(event.getYoffset()) > 0) {
        updateScrollBarValue(event.getYoffset(), event.getContext(), event.getFrame(), textArea.getVerticalScrollBar());
    }
    if (Math.abs(event.getXoffset()) > 0) {
        updateScrollBarValue(event.getXoffset(), event.getContext(), event.getFrame(), textArea.getHorizontalScrollBar());
    }
}
Also used : ScrollablePanel(com.spinyowl.legui.component.ScrollablePanel) TextArea(com.spinyowl.legui.component.TextArea) Vector2f(org.joml.Vector2f) ArrayList(java.util.ArrayList) Component(com.spinyowl.legui.component.Component)

Aggregations

Component (com.spinyowl.legui.component.Component)1 ScrollablePanel (com.spinyowl.legui.component.ScrollablePanel)1 TextArea (com.spinyowl.legui.component.TextArea)1 ArrayList (java.util.ArrayList)1 Vector2f (org.joml.Vector2f)1