use of com.spinyowl.legui.listener.FocusEventListener in project legui by SpinyOwl.
the class SelectBox method initialize.
/**
* Used to initialize selectbox.
*/
private void initialize() {
selectionListPanel.setHorizontalScrollBarVisible(false);
selectionListPanel.getContainer().getStyle().setDisplay(DisplayType.FLEX);
selectionListPanel.getContainer().getStyle().getFlexStyle().setFlexDirection(FlexDirection.COLUMN);
selectionListPanel.getContainer().getStyle().getBackground().setColor(ColorConstants.lightBlue());
this.getStyle().setDisplay(DisplayType.FLEX);
expandIcon = new CharIcon(new Vector2f(expandButton.getSize()), DEFAULT_ICON_FONT, (char) EXPAND_ICON_CHAR, ColorConstants.black());
collapseIcon = new CharIcon(new Vector2f(expandButton.getSize()), DEFAULT_ICON_FONT, (char) COLLAPSE_ICON_CHAR, ColorConstants.black());
expandButton.getStyle().getBackground().setIcon(expandIcon);
expandButton.getStyle().setMinimumSize(buttonWidth, 0);
expandButton.getStyle().setMaximumSize(buttonWidth, Float.MAX_VALUE);
expandButton.getStyle().setRight(0f);
expandButton.getStyle().setTop(0f);
expandButton.getStyle().setBottom(0f);
selectionButton.getStyle().setTop(0f);
selectionButton.getStyle().setLeft(0f);
selectionButton.getStyle().setBottom(0f);
selectionButton.getStyle().setRight(buttonWidth);
this.add(expandButton);
this.add(selectionButton);
MouseClickEventListener mouseClickEventListener = new SelectBoxClickListener<>(this);
selectionButton.getListenerMap().addListener(MouseClickEvent.class, mouseClickEventListener);
expandButton.getListenerMap().addListener(MouseClickEvent.class, mouseClickEventListener);
selectBoxLayer.getListenerMap().addListener(MouseClickEvent.class, mouseClickEventListener);
FocusEventListener focusEventListener = new SelectBoxFocusListener<>(this);
selectionListPanel.getVerticalScrollBar().getListenerMap().getListeners(FocusEvent.class).add(focusEventListener);
selectionButton.getListenerMap().getListeners(FocusEvent.class).add(focusEventListener);
expandButton.getListenerMap().getListeners(FocusEvent.class).add(focusEventListener);
selectBoxLayer.add(selectionListPanel);
SelectBoxAnimation animation = new SelectBoxAnimation(this, selectionListPanel);
animation.startAnimation();
Themes.getDefaultTheme().getThemeManager().getComponentTheme(SelectBox.class).applyAll(this);
}
Aggregations