Closed federicovilla55 closed 1 week ago
sorry for the delay; been on vacation for the past few weeks.
Thank you for looking into this - awesome that we're going to have a fix for this in WASM! have you tested this by running a local WASM build and (Linux | Windows) build to ensure that it works in both scenarios?
I've tested the PR with both local WASM and Linux/Windows builds, and it works in all cases. Let me know if there are any other scenarious I should check.
@federicovilla55 sorry for the delay (feel free to ping me if i'm not replying)... awesome - we'll merge it :)
In the current WebAssembly (WASM) version of Ripes there's an issue preventing input reading from the console. This because pressing
Enter
does not return control to the processor, as stated in issue #304.The problems stems from the behaviour of the
Console::keyPressEvent(QKeyEvent *e)
method, which requires aQKeyEvent
parameter, that appears to behave differently in the binary executable compared to the WASM version. In the binary executable, when pressing Enter or Return, theQKeyEvent
associated with the keysQt::Key_Return
orQt::Key_Enter
has a non empty text field (e->text()
). However, in the WASM version that field is empty and therefore the checkif (!e->text().isEmpty())
always returns false when pressing Enter, resulting in the already reported error. The same happens with the Backspace Key.Proposed fix
I propose altering the handling of these events: rather than mandating a non-empty text field in the
QKeyEvent
, I suggest to verify only the key associated with each command. Text inspection should only occur for the events where the key is not checked.As stated in the Qt documentation of the QKeyEvent Class of
key()
:The
key()
of an event is independent from the underlying system while thetext()
may not.In the modified code, all types of
QKeyEvent
are processed using the same switch-case structure, as currently happens for the directional keys. When a key event is triggered, the program checks if the key corresponds to any of the arrow keys, the Enter key, the Return key or the Backspace key. If the key does not match any of these, the event is handled as it used to: first, it checks that the content of the key event is not empty, ensuring that modifier keys such as Shift, Control, or Alt are not considered. Then, it adds the content of the event to the buffer and calls theputData()
method.