/** * Unfocuses the currently focused widget. */ public static void unfocusWidget() { if (focusedWidget != null) { focusSetThrough = true; focusedWidget = null; openScreen.getManager().setFocus(null); } }
@Override public void onOpened() { super.onOpened(); getManager().setFocus(commandLine); }
@Override public boolean onMouseClick(NUIMouseClickEvent event) { if (event.getMouseButton() == MouseInput.MOUSE_LEFT && commandLine != null) { getManager().setFocus(commandLine); } return true; } };
@Override public boolean onMouseClick(NUIMouseClickEvent event) { if (event.getMouseButton() == MouseInput.MOUSE_LEFT && commandLine != null) { getManager().setFocus(commandLine); } return true; } };
@Override public void onOpened() { super.onOpened(); getManager().setFocus(commandLine); if (!welcomePrinted) { console.addMessage("Welcome to the wonderful world of Terasology!" + Console.NEW_LINE + Console.NEW_LINE + "Type 'help' to see a list with available commands or 'help <commandName>' for command details." + Console.NEW_LINE + "Text parameters do not need quotes, unless containing spaces. No commas between parameters." + Console.NEW_LINE + "You can use auto-completion by typing a partial command then hitting [tab] - examples:" + Console.NEW_LINE + Console.NEW_LINE + "gh + [tab] => 'ghost'" + Console.NEW_LINE + "help gh + [tab] => 'help ghost' (can auto complete commands fed to help)" + Console.NEW_LINE + "giv + [tab] => 'give givePermission' (use [tab] again to cycle between choices)" + Console.NEW_LINE + "lS + [tab] => 'listShapes' (camel casing abbreviated commands)" + Console.NEW_LINE); welcomePrinted = true; } }
@Override public void onOpened() { super.onOpened(); serverInfo = null; successFunc = null; ownerText.setText(null); nameText.setText(null); addressText.setText(null); portText.setText(Integer.toString(TerasologyConstants.DEFAULT_PORT)); portText.setCursorPosition(portText.getText().length()); getManager().setFocus(nameText); }
@Override public void postRender() { drawOnTopOperations.forEach(DrawOperation::draw); drawOnTopOperations.clear(); if (topMouseOverRegion != null && time.getGameTime() >= tooltipTime && getSkin() != null) { tooltipWidget.setAttachment(topMouseOverRegion.getTooltip()); drawWidget(tooltipWidget); } else { tooltipWidget.setAttachment(null); } renderer.postRender(); if (!focusDrawn) { nuiManager.setFocus(null); } }
/** * Sets the interface focus to the inline editor widget and selects a subset of its' contents. * * @param node The node that is currently being edited. * @param inlineEditorEntry The inline editor widget. */ protected void focusInlineEditor(JsonTree node, UITextEntry inlineEditorEntry) { getManager().setFocus(inlineEditorEntry); inlineEditorEntry.resetValue(); if (node.getValue().getType() == JsonTreeValue.Type.KEY_VALUE_PAIR) { // If the node is a key/value pair, select the value of the node. if (node.getValue().getValue() instanceof String) { inlineEditorEntry.setCursorPosition(node.getValue().getKey().length() + "\"\":\"".length(), true); inlineEditorEntry.setCursorPosition(inlineEditorEntry.getText().length() - "\"".length(), false); } else { inlineEditorEntry.setCursorPosition(node.getValue().getKey().length() + "\"\":".length(), true); inlineEditorEntry.setCursorPosition(inlineEditorEntry.getText().length(), false); } } else { // Otherwise fully select the contents of the node. inlineEditorEntry.setCursorPosition(0, true); inlineEditorEntry.setCursorPosition(inlineEditorEntry.getText().length(), false); } }
@Override public boolean processMouseWheel(int wheelTurns, Vector2i pos) { for (InteractionRegion next : mouseOverRegions) { if (next.region.contains(pos)) { Vector2i relPos = new Vector2i(pos); relPos.sub(next.region.min()); if (next.listener.onMouseWheel(new NUIMouseWheelEvent(mouse, keyboard, relPos, wheelTurns))) { clickedRegion = next; nuiManager.setFocus(next.element); return true; } } } return false; }
@Override public boolean processMouseClick(MouseInput button, Vector2i pos) { TabbingManager.focusSetThrough = false; TabbingManager.resetCurrentNum(); boolean possibleDoubleClick = lastClickPosition.gridDistance(pos) < MAX_DOUBLE_CLICK_DISTANCE && lastClickButton == button && time.getGameTimeInMs() - lastClickTime < DOUBLE_CLICK_TIME; lastClickPosition.set(pos); lastClickButton = button; lastClickTime = time.getGameTimeInMs(); for (InteractionRegion next : mouseOverRegions) { if (next.region.contains(pos)) { Vector2i relPos = new Vector2i(pos); relPos.sub(next.offset); if (possibleDoubleClick && nuiManager.getFocus() == next.element) { if (next.listener.onMouseDoubleClick(createDoubleClickEvent(button, relPos))) { clickedRegion = next; return true; } } else if (next.listener.onMouseClick(createClickEvent(button, relPos))) { clickedRegion = next; nuiManager.setFocus(next.element); return true; } } } return false; }
getManager().setFocus(commandLine);
getManager().setFocus(commandLine); commandLine.setTabCompletionEngine(new CyclingTabCompletionEngine(console, localPlayer)); commandLine.bindCommandHistory(new ReadOnlyBinding<List<String>>() {
widget.onGainFocus(); TabbingManager.focusedWidget = widget; TabbingManager.getOpenScreen().getManager().setFocus(widget);