Using JGo 5.2 (beta) I have a Comment class from the Demo1 example and set it so it is multiline and resizable. The client wants both autowrap and the ability to enter a newline, however with autowrap on, a carrige rerturn causes the edit to terminate. The Escape key aborts the edit.
Since Comment has a JGoText and the JGoTextEdit key handler is the place that CR and ESC are handled, it seems I must edit the source code and build my own version of JGoText and JGoTextEdit for use in a modified Comment class. Is there any easier way to accomplish the customers goal of having both autowrap and being able to enter a CR or newline in a Comment? Ideally ESC would close the edit without throwing away the edited text.
From JGoTextEdit below:
protected void processKeyEvent(KeyEvent e) {
JGoTextEdit editor = myTextEdit;
if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == JGoView.Key_ENTER && editor != null) {
myTextEdit = null;
if (editor.setEditedText(this.getText(), myView)) { // set new text
editor.doEndEdit(); // remove editor
} else {
myTextEdit = editor; // restore back-pointer and keep editing
}
return;
} else if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == JGoView.Key_ESCAPE && editor != null) {
myTextEdit = null;
// don’t set new text
editor.doEndEdit();
return;
}
super.processKeyEvent(e);
}