New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard: avoid additional key stroke on hold release #5573
Conversation
Added some forgotten return true on hold release event handlers: the event would otherwise trigger a tap (as we generate a tap normally only at release time) and cause duplicate key strokes.
The behavior is still incorrect though.
If the modal behavior were as it should be (i.e., as it was prior to #5452) then there would be nothing to "fix." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, this will do for now I suppose.
@@ -241,21 +244,31 @@ function VirtualKey:onSwipeKey(arg, ges) | |||
end | |||
|
|||
function VirtualKey:onHoldReleaseKey() | |||
if self.ignore_key_release then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is @#$@# ugly though. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I rescind that, I really hate this workaround. It hurts my eyes. :-P
I don't understand much about that modal stuff - and hardly a bit much about the inner working of your key popups. And having a quick look at that uimanager stuff, it look to me that #5452 is naturally correct. Before it, may be the events didn't reach the keyboard because something there in uimanager was (incorrectly) not sending them. But now they are, as I think they should. Having that fixed so far away in uimanager looks like far fetched side effect :) |
You can think of a modal dialog as a fullscreen widget for most intents and purposes. You wouldn't expect to be able to interact with anything below the fullscreen widget, quite the contrary. However, modal dialogs are arguably overused, including in KOReader. Does the wifi dialog even need to be modal? (The answer is probably affirmative within our context, because it might get lost behind other widgets.)
Not a bug exactly, at least not here, but more of a good practice to possibly prevent a few wasted CPU cycles.
But how are you overriding it to remove the line on hold? |
On my 2 unwanted delChar was solved by the return true. The other one by the self.ignore_key_release.
The removal of the line is done by the hold_callback, which is done on the "hold" event by: koreader/frontend/ui/widget/virtualkeyboard.lua Lines 129 to 134 in f1f75c5
handled by: koreader/frontend/ui/widget/virtualkeyboard.lua Lines 206 to 214 in f1f75c5
A tap on a normal key is handled by: koreader/frontend/ui/widget/virtualkeyboard.lua Lines 123 to 128 in f1f75c5
which calls: koreader/frontend/ui/widget/virtualkeyboard.lua Lines 187 to 195 in f1f75c5
But this one is also called when hold on a normal key (so, a slow tap): koreader/frontend/ui/widget/virtualkeyboard.lua Lines 135 to 140 in f1f75c5
handled by: koreader/frontend/ui/widget/virtualkeyboard.lua Lines 243 to 250 in f1f75c5
So, 2 way to handle tap: quick tap, and slow tap that appears like a hold. |
I simply didn't realize that hold to remove a line was built-in behavior. Anyway, note that #5452 resulted in three removals as opposed to what looks like the intended two. So this PR could still make sense if you only want one. |
I intended only one: the removal to start of line, not the removal of the Regarding this modal stuff handling: koreader/frontend/ui/uimanager.lua Lines 683 to 707 in f1f75c5
We have modal: koreader/frontend/ui/widget/virtualkeyboard.lua Lines 502 to 503 in f1f75c5
koreader/frontend/ui/widget/virtualkeyboard.lua Lines 270 to 271 in f1f75c5
So, if your modal popup key don't consume the event, it looks normal (but may be not correct) with this code that some other modal will get it: the keyboard, which I guess will give it to some VirtualKey, so your bug. |
No, absolutely not! That's why #5452 is dead wrong. A modal dialog should always be modal. The very idea of "some other modal" makes no sense. |
If the wifi dialog pops up first and then another modal dialog opens on top of it then the wifi dialog should not be accessible. The problem is that the caller there called two modal dialogs in a row. Only modal dialogs themselves are ever supposed to call other modal dialogs. |
OK. |
OK, with #5574 and this one, I don't notice any issue. So I hope we're fine on the keyboard side. |
Could you clarify that? The behavior described in #5573 (comment) and #5415 suggests that it behaves correctly. |
Yes, with your added But if it is set to modal, and if we had forgotten this |
But that return true isn't responsible for that behavior. |
OK, forget about that keyboard and that return true. I have enough of it :) But generically: sendEvent => modal widget handler not returning true => propagated to lower non-modal widgets. Correct behaviour or bug? |
If that happened, that would be a bug. (Assuming that |
Added some forgotten
return true
on hold release event handlers: the event would otherwise triggera tap (as we generate a tap normally only at release time) and cause duplicate key strokes.
Details in #5555 (comment). Closes #5555.
(I included your suggested fix for the keyboard popup, as it's more related to my other fixes. You might want to remove it from #5569).