When I press on a text field in PolyScope, no keyboard is displayed. For example, I want to enter a title as shown in the image below. Does anyone know how this can be done?
If you are using the starter package, it contains some example URCaps that use keyboards. I would recommend reading through their implementation to get a better idea of how to make keyboard API calls.
I hope this all helps!
The following links could be of some benefit for reference in developing swing objects:
- Universal Robots - URCap - Choosing Swing or HTML (universal-robots.com)
- KeyboardInputFactory (api 1.13.0 API) (universal-robots.com)
- Universal Robots - URCap - API Reference Docs (universal-robots.com)
Here is an example from the first link I provided:
VIEW CLASS
private Box createInputBox(final JTextField textField,
final ContributionProvider<samplesProgramNodeContribution> provider) {
Box box = Box.createHorizontalBox();
box.setAlignmentX(Component.LEFT_ALIGNMENT);
textField.setFocusable(false);
textField.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
KeyboardTextInput keyboardInput = provider.get().getKeyboardForInput();
keyboardInput.show(textField, provider.get().getKeyBoardCallBack());
}
});
box.add(textField);
return box;
}
public void setINPUTtextField(String text) {
this.inputTextField.setText(text);
}
CONTRIBUTION CLASS
private static final String INPUT_KEY = "input_key";
private static final String INPUT_DEFAULT_VALUE = "not set";
public KeyboardTextInput getKeyboardForInput() {
KeyboardTextInput keyboard = keyboardInputFactory.createStringKeyboardInput();
return keyboard;
}
public KeyboardInputCallback<String> getKeyBoardCallBack() {
return new KeyboardInputCallback<String>() {
@Override
public void onOk(String value) {
final String inputText = value;
undoRedoManager.recordChanges(new UndoableChanges() {
@Override
public void executeChanges() {
model.set(INPUT_KEY, inputText);
}
});
view.setINPUTtextField("Your input is: " + model.get(INPUT_KEY, INPUT_DEFAULT_VALUE));
}
};
}