/** * If this key is pressed, {@link #result(Object)} is called with the specified object. * @see Keys */ public VisDialog key (final int keycode, final Object object) { addListener(new InputListener() { @Override public boolean keyDown (InputEvent event, int keycode2) { if (keycode == keycode2) { result(object); if (!cancelHide) hide(); cancelHide = false; } return false; } }); return this; }
@Override protected void setStage (Stage stage) { if (stage == null) addListener(focusListener); else removeListener(focusListener); super.setStage(stage); }
/** * Dialog with given text and single OK button. * @param title dialog title */ public static VisDialog showOKDialog (Stage stage, String title, String text) { final VisDialog dialog = new VisDialog(title); dialog.closeOnEscape(); dialog.text(text); dialog.button(ButtonType.OK.getText()).padBottom(3); dialog.pack(); dialog.centerWindow(); dialog.addListener(new InputListener() { @Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Keys.ENTER) { dialog.fadeOut(); return true; } return false; } }); stage.addActor(dialog.fadeIn()); return dialog; }
@LmlAfter void initView() { timerAction = new TimerAction(NOTIFICATION_CUTOFF, new Timer.Listener() { @Override public void onTimeUp() { updateProjectProperty(); } }); stage.addAction(timerAction); originalColor.set(modelService.getProject().getPreviewBackgroundColor()); selectedColor.set(originalColor); colorPicker.setColor(selectedColor); // Close dialog on ESC dialog.addListener(new InputListener() { @Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Input.Keys.ESCAPE) { onCancelClick(); return true; } return false; } }); VisImageButton btnClose = WidgetUtils.obtainCloseButton(dialog); btnClose.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { onCancelClick(); } }); }