public void onSoftText(int action, String text) { if (action == SoftTextDialogInputListener.COMPLETE) { textField.setText(text); } } });
@NiftyEventSubscriber(id="DeviceListBox") public void onDeviceChanged(String id, ListBoxSelectionChangedEvent<String> event) { String d = event.getSelection().isEmpty() ? null : event.getSelection().get(0); LOG.log(Level.INFO, "Selected device changed to {0}", d); selectedDevice = d; }
private void changePlatform(String platform) { selectedPlatform = platform; Platform p = null; for (Platform p2 : availabePlatforms) { if (p2.getName().equals(selectedPlatform)) { p = p2; break; } } deviceListBox.clear(); if (p == null) { return; } for (Device d : p.getDevices()) { deviceListBox.addItem(d.getName()); } deviceListBox.selectItem(selectedDevice); }
private void processSoftKeyboard() { SoftTextDialogInput softTextDialogInput = JmeSystem.getSoftTextDialogInput(); if (softTextDialogInput != null) { Element element = nifty.getCurrentScreen().getFocusHandler().getKeyboardFocusElement(); if (element != null) { final TextField textField = element.getNiftyControl(TextField.class); if (textField != null) { Logger.getLogger(InputSystemJme.class.getName()).log(Level.FINE, "Current TextField: {0}", textField.getId()); String initialValue = textField.getRealText(); if (initialValue == null) { initialValue = ""; } softTextDialogInput.requestDialog(SoftTextDialogInput.TEXT_ENTRY_DIALOG, "Enter Text", initialValue, new SoftTextDialogInputListener() { public void onSoftText(int action, String text) { if (action == SoftTextDialogInputListener.COMPLETE) { textField.setText(text); } } }); } } } } }
@Override public void onEvent(final String topic, final ButtonClickedEvent data) { Element element = data.getButton().getElement(); if (element != null) { parentControl.processButtonClick(element); } } }
private void initialFill() { if (listBox != null) { for (int i = 0; i < listBox.getDisplayItemCount(); i++) { listBox.addItem(""); } } }
@Override public void onFocus(final boolean arg0) { if (textControl != null) { textControl.setFocus(); } }
private void updateInfos() { if (testBuffer == null && clContext != null && !bufferCreated) { try { testBuffer = clContext.createBuffer(1024).register(); LOG.info("Test buffer created"); } catch (OpenCLException ex) { LOG.log(Level.SEVERE, "Unable to create buffer", ex); } bufferCreated = true; } Context c = context.getOpenCLContext(); if (c == clContext) { return; } clContext = c; LOG.info("context changed"); testBuffer = null; bufferCreated = false; StringBuilder text = new StringBuilder(); text.append("Current context:\n"); text.append(" Platform: ").append(clContext.getDevices().get(0).getPlatform().getName()).append("\n"); text.append(" Device: ").append(clContext.getDevices().get(0).getName()).append("\n"); text.append(" Profile: ").append(clContext.getDevices().get(0).getProfile()).append("\n"); text.append(" Memory: ").append(clContext.getDevices().get(0).getGlobalMemorySize()).append(" B\n"); text.append(" Compute Units: ").append(clContext.getDevices().get(0).getComputeUnits()).append("\n"); infoLabel.setText(text.toString()); }
@Override public boolean hasFocus() { final Element element = getElement(); if (element == null) { return false; } return element == element.getFocusHandler().getKeyboardFocusElement(); }
@Override public void onFocus(final boolean getFocus) { super.onFocus(getFocus); } }
/** * add the given element to the focushandler (as the last element). * * @param element element to add */ public void addElement(final Element element) { addElement(element, null); }
/** * forward the onForward method to the controller. * * @param getFocus get focus */ public void onFocus(final boolean getFocus) { controller.onFocus(getFocus); }
private void postDragActions() { if (disableAtEndOfDrag) { disableAtEndOfDrag = false; super.disable(); } }
public void setIgnoreKeyboardEvents(final boolean newValue) { ignoreKeyboardEvents = newValue; if (newValue) { focusHandler.lostKeyboardFocus(this); } }
@Override @SuppressWarnings("unchecked") public void bind(Nifty nifty, Screen screen) { applyButton = screen.findNiftyControl("ApplyButton", Button.class); platformListBox = screen.findNiftyControl("PlatformListBox", ListBox.class); deviceListBox = screen.findNiftyControl("DeviceListBox", ListBox.class); infoLabel = screen.findNiftyControl("InfoLabel", Label.class); updateInfos(); platformListBox.clear(); for (Platform p : availabePlatforms) { platformListBox.addItem(p.getName()); } platformListBox.selectItem(selectedPlatform); changePlatform(selectedPlatform); }
@Override public void onEvent(final String topic, @Nonnull final ButtonClickedEvent data) { Element element = data.getButton().getElement(); if (element != null) { parentControl.processButtonClick(element); } } }
private void initialFill() { if (listBox != null) { for (int i = 0; i < listBox.getDisplayItemCount(); i++) { listBox.addItem(""); } } }
@NiftyEventSubscriber(id="PlatformListBox") public void onPlatformChanged(String id, ListBoxSelectionChangedEvent<String> event) { String p = event.getSelection().isEmpty() ? null : event.getSelection().get(0); LOG.log(Level.INFO, "Selected platform changed to {0}", p); selectedPlatform = p; changePlatform(p); }
@Override public void onFocus(final boolean arg0) { if (textControl != null) { textControl.setFocus(); } }
@Override public void onStartScreen() { if (textfield != null) { textfield.setFocus(); } }