use of com.spinyowl.legui.event.MouseClickEvent in project legui by SpinyOwl.
the class SplitPanelSeparatorListenerDelegate method process.
/**
* Used to handle specific event.
*
* @param event event to handle.
*/
@Override
public void process(Event event) {
if (!event.getTargetComponent().equals(splitPanel.getSeparator())) {
return;
}
if (event instanceof MouseClickEvent) {
MouseClickEvent e = (MouseClickEvent) event;
if (e.getAction() == PRESS) {
dragging = true;
}
if (e.getAction() == RELEASE) {
dragging = false;
CursorServiceProvider.getInstance().setCursor(Cursor.ARROW, e.getContext());
}
}
if (event instanceof CursorEnterEvent) {
CursorEnterEvent e = (CursorEnterEvent) event;
Orientation orientation = splitPanel.getOrientation();
if (e.isEntered() && orientation == HORIZONTAL) {
CursorServiceProvider.getInstance().setCursor(Cursor.H_RESIZE, e.getContext());
} else if (e.isEntered() && orientation != HORIZONTAL) {
CursorServiceProvider.getInstance().setCursor(Cursor.V_RESIZE, e.getContext());
} else if (!dragging) {
CursorServiceProvider.getInstance().setCursor(Cursor.ARROW, e.getContext());
}
}
}
use of com.spinyowl.legui.event.MouseClickEvent in project legui by SpinyOwl.
the class ExampleGui method createButtonWithTooltip.
private Button createButtonWithTooltip() {
Button button = new Button(20, 170, 50, 20);
/*button.getStyle().getBackground().setColor(new Vector4f(1));*/
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) System.out::println);
Tooltip tooltip = new Tooltip("Just button");
button.setTooltip(tooltip);
tooltip.setPosition(0, 25);
tooltip.getSize().set(50, 60);
tooltip.getStyle().setPadding(4f);
tooltip.getListenerMap().addListener(TooltipTextSizeChangeEvent.class, e -> tooltip.setSize(50, e.getHeight()));
int[] idv = { 0 };
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) (MouseClickEvent event) -> {
if (event.getAction().equals(CLICK)) {
idv[0]++;
HorizontalAlign h;
VerticalAlign v;
int hh = idv[0] % 3;
int vv = (idv[0] / 3) % 3;
switch(hh) {
case 0:
h = LEFT;
break;
case 1:
h = CENTER;
break;
case 2:
default:
h = RIGHT;
break;
}
switch(vv) {
case 0:
v = TOP;
break;
case 1:
v = MIDDLE;
break;
case 2:
default:
v = BOTTOM;
break;
}
System.out.println(h + " " + v);
tooltip.getStyle().setHorizontalAlign(h);
tooltip.getStyle().setVerticalAlign(v);
}
});
return button;
}
Aggregations