I am currently working on an application using the HaxeUI library. In my application, I am creating TextInput objects, which are based off of OpenFL’s TextField. Unfortunately, when compiling for Windows or Neko, these fields do not allow for basic faculties like Ctrl+V, Ctrl+C, or Ctrl+A.
As a result, I felt that I could just make my own extension of the TextInput class which simply uses the KeyboardEvent.KEY_DOWN event to detect these particular functions. The below is a relevant snippet of my implementation:
class SmartTextInput extends TextInput {
public function new() {
super();
this.addEventListener(KeyboardEvent.KEY_DOWN, performPress);
}
private function performPress(e:KeyboardEvent):Void {
if(e.ctrlKey) {
trace("CTRL PRESSED!");
switch(e.keyCode) {
case Keyboard.V: trace("PASTE!");
}
}
}
}
It looks like if I press Ctrl and then V, it should print out “CTRL PRESSED!” and “PASTE!”. However, I only ever get “CTRL PRESSED!”, so it doesn’t work. In fact, after some vigorous testing, I found that if
the CTRL button is being held, then KeyboardEvent.KEY_DOWN will not register any other keypress except the ALT and SHIFT keys. In other words, detecting Ctrl and V being held simultaneously is impossible unless V is pressed first; however, sinceconventionally Ctrl is pressed first, this doesn’t work for me.
Is there a way I can register actions like Ctrl+V in a TextField in OpenFL for Windows? Or at least, is there a way I can detect the sequential key presses of Ctrl, followed by V? I’ve tried having Ctrl on KEY_DOWN and V on KEY_UP, but it is not responsive enough for practical use.
I am using OpenFL 3.6.0, Lime 2.9.0, and HaxeUI 1.8.17. It should be noted that HaxeUI requires OpenFL Legacy. In non-legacy OpenFL, I was able to get Ctrl+V working just fine.