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, since conventionally 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.
This is why they made OpenFL next. I'm not sure if it's not possible or not easy to detect those keypresses in legacy, but I highly doubt that functionality would be added at this point since you got it to work with next.
So it's kind of a "Will OpenFL add to their legacy codebase?" versus "When does the next major version of HaxeUI come out?" There are enough issues with TextFields on next that they're probably not going to also fix legacy's longstanding problems. And a new HaxeUI is coming eventually.
So... no you can't. Not yet.