mirror of
https://github.com/sojamo/controlp5
synced 2024-11-16 11:17:56 +01:00
27 lines
851 B
Java
27 lines
851 B
Java
|
package main.java.src2.main.java.controlP5.controlP5;
|
||
|
|
||
|
import processing.event.KeyEvent;
|
||
|
|
||
|
public class MultilineTextfield extends Textfield {
|
||
|
|
||
|
public MultilineTextfield(ControlP5 theControlP5, String theName) {
|
||
|
super(theControlP5, theName);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void keyEvent(KeyEvent theKeyEvent) {
|
||
|
if (isUserInteraction && isTexfieldActive && isActive && theKeyEvent.getAction() == KeyEvent.PRESS) {
|
||
|
if (ignorelist.contains(cp5.getKeyCode())) {
|
||
|
return;
|
||
|
}
|
||
|
if (cp5.getKeyCode() == ENTER) {
|
||
|
// Append a new line character to the text buffer
|
||
|
_myTextBuffer.insert(_myTextBufferIndex, '\n');
|
||
|
setIndex(_myTextBufferIndex + 1);
|
||
|
} else {
|
||
|
super.keyEvent(theKeyEvent);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|