/** Initializes the builder and sets it up to build a new {@link HttpRequest} . */ public HttpRequestBuilder newRequest () { if (httpRequest != null) { throw new IllegalStateException("A new request has already been started. Call HttpRequestBuilder.build() first."); } httpRequest = Pools.obtain(HttpRequest.class); httpRequest.setTimeOut(defaultTimeout); return this; }
/** Initializes the builder and sets it up to build a new {@link HttpRequest} . */ public HttpRequestBuilder newRequest () { if (httpRequest != null) { throw new IllegalStateException("A new request has already been started. Call HttpRequestBuilder.build() first."); } httpRequest = Pools.obtain(HttpRequest.class); httpRequest.setTimeOut(defaultTimeout); return this; }
/** Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button. Touch focus * is added automatically when true is returned from {@link InputListener#touchDown(InputEvent, float, float, int, int) * touchDown}. The specified actors will be used as the {@link Event#getListenerActor() listener actor} and * {@link Event#getTarget() target} for the touchDragged and touchUp events. */ public void addTouchFocus (EventListener listener, Actor listenerActor, Actor target, int pointer, int button) { TouchFocus focus = Pools.obtain(TouchFocus.class); focus.listenerActor = listenerActor; focus.target = target; focus.listener = listener; focus.pointer = pointer; focus.button = button; touchFocuses.add(focus); }
/** Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button. Touch focus * is added automatically when true is returned from {@link InputListener#touchDown(InputEvent, float, float, int, int) * touchDown}. The specified actors will be used as the {@link Event#getListenerActor() listener actor} and * {@link Event#getTarget() target} for the touchDragged and touchUp events. */ public void addTouchFocus (EventListener listener, Actor listenerActor, Actor target, int pointer, int button) { TouchFocus focus = Pools.obtain(TouchFocus.class); focus.listenerActor = listenerActor; focus.target = target; focus.listener = listener; focus.pointer = pointer; focus.button = button; touchFocuses.add(focus); }
/** @param oldText May be null. * @return True if the text was changed. */ boolean changeText (String oldText, String newText) { if (newText.equals(oldText)) return false; text = newText; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); text = cancelled ? oldText : newText; Pools.free(changeEvent); return !cancelled; }
/** @param oldText May be null. * @return True if the text was changed. */ boolean changeText (String oldText, String newText) { if (newText.equals(oldText)) return false; text = newText; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); text = cancelled ? oldText : newText; Pools.free(changeEvent); return !cancelled; }
/** Fires a change event on the selection's actor, if any. Called internally when the selection changes, depending on * {@link #setProgrammaticChangeEvents(boolean)}. * @return true if the change should be undone. */ public boolean fireChangeEvent () { if (actor == null) return false; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); try { return actor.fire(changeEvent); } finally { Pools.free(changeEvent); } }
/** Fires a change event on the selection's actor, if any. Called internally when the selection changes, depending on * {@link #setProgrammaticChangeEvents(boolean)}. * @return true if the change should be undone. */ public boolean fireChangeEvent () { if (actor == null) return false; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); try { return actor.fire(changeEvent); } finally { Pools.free(changeEvent); } }
void setChecked (boolean isChecked, boolean fireEvent) { if (this.isChecked == isChecked) return; if (buttonGroup != null && !buttonGroup.canCheck(this, isChecked)) return; this.isChecked = isChecked; if (fireEvent) { ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); if (fire(changeEvent)) this.isChecked = !isChecked; Pools.free(changeEvent); } }
void setChecked (boolean isChecked, boolean fireEvent) { if (this.isChecked == isChecked) return; if (buttonGroup != null && !buttonGroup.canCheck(this, isChecked)) return; this.isChecked = isChecked; if (fireEvent) { ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); if (fire(changeEvent)) this.isChecked = !isChecked; Pools.free(changeEvent); } }
public void touchUp (InputEvent event, float x, float y, int pointer, int button) { if (pointer != draggingPointer) return; draggingPointer = -1; // The position is invalid when focus is cancelled if (event.isTouchFocusCancel() || !calculatePositionAndValue(x, y)) { // Fire an event on touchUp even if the value didn't change, so listeners can see when a drag ends via isDragging. ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); fire(changeEvent); Pools.free(changeEvent); } }
public void touchUp (InputEvent event, float x, float y, int pointer, int button) { if (pointer != draggingPointer) return; draggingPointer = -1; // The position is invalid when focus is cancelled if (event.isTouchFocusCancel() || !calculatePositionAndValue(x, y)) { // Fire an event on touchUp even if the value didn't change, so listeners can see when a drag ends via isDragging. ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); fire(changeEvent); Pools.free(changeEvent); } }
/** Applies a key down event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns * true if the event was {@link Event#handle() handled}. */ public boolean keyDown (int keyCode) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyDown); event.setKeyCode(keyCode); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key typed event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns * true if the event was {@link Event#handle() handled}. */ public boolean keyTyped (char character) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyTyped); event.setCharacter(character); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key up event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns true * if the event was {@link Event#handle() handled}. */ public boolean keyUp (int keyCode) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyUp); event.setKeyCode(keyCode); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key down event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns * true if the event was {@link Event#handle() handled}. */ public boolean keyDown (int keyCode) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyDown); event.setKeyCode(keyCode); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key up event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns true * if the event was {@link Event#handle() handled}. */ public boolean keyUp (int keyCode) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyUp); event.setKeyCode(keyCode); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key typed event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns * true if the event was {@link Event#handle() handled}. */ public boolean keyTyped (char character) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyTyped); event.setCharacter(character); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a mouse scroll event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the * event. This event only occurs on the desktop. */ public boolean scrolled (int amount) { Actor target = scrollFocus == null ? root : scrollFocus; screenToStageCoordinates(tempCoords.set(mouseScreenX, mouseScreenY)); InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.scrolled); event.setScrollAmount(amount); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a mouse scroll event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the * event. This event only occurs on the desktop. */ public boolean scrolled (int amount) { Actor target = scrollFocus == null ? root : scrollFocus; screenToStageCoordinates(tempCoords.set(mouseScreenX, mouseScreenY)); InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.scrolled); event.setScrollAmount(amount); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }