[InputText] decouple text input state from VirtualKeyboard visibility pt. 2#14937
Conversation
|
grandad @poire-z wake up from your nap, it's almost Friday now. |
| else | ||
| if self.keyboard then | ||
| self.keyboard:showKeyboard() | ||
| if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then |
There was a problem hiding this comment.
technically speaking, a K4 (i.e., hasScreenKB) will never be around here but this way it is consistent with all other ones
There was a problem hiding this comment.
and I forgot to say, this can't go in the function, as that function is used to pop the vk with shift+home, so it needs to be able to bring it up regardless
|
Continued from #14901 (comment) I'm not fond of this hack. From the perspective of the text input the arrow keys don't work as you'd expect or anything; from the perspective of the VK the focus is completely random. |
|
Just to clear up. Focusing on enter is as much a hack as deleting all key events. That is simply my suggestion but if there are others, happy to hear them, otherwise we can't have a working vk at all (with a keyboard), same as before |
Sorry, I had to take a job at the grocery store... KOReader doesn't pay, and you kids eat (and shit PRs) a lot :/ |
|
in case anyone is wondering why the seemingly random QR change, Text Editor has a qr button, and pressing esc was triggering a close event ;) |
|
Yes, I agree it seems better without the VK ever taking focus (except in non-touch mode), making that comment not a hack but simply desired.
We do distinguish a mere isSDL and isEmulator in some conditions but this doesn't seem like one where that distinction makes sense. It's mainly for doing things like fake sleeping/screensaver and fake frontlight/warmth dialogs. |
|
I should mention, when the vk is up shift+up/down/left/right move the cursor inside inputtext |
|
right so, I have delivered a system that works equally whether you have a vk on or not. I have consciously uncoupled the state of the vk to typing from. a physical keyboard. @Frenzie I hand over to you what you want to do regarding the issue of the vk on and focus, I trust you'll do whatever you consider best. I'll say one more thing, it is not unheard of, cases where people don't/didn't have a mouse and needed the whole thing to be usable with just the keyboard.. |
Was this PR ready to go besides that enter key hack? |
I believe it fixes all the concerns @poire-z had. |
…loop Due to the way this was wired, koreader#14937 trigged BookStatusWidget:onSwitchFocus() when closing, which caused the review input dialog to pop right back up again. But it doesn't look like you're actually supposed to be able to type in there at all, so I replaced it with a TextBoxWidget.
|
#15055 is the result of peering at my code for probably over 20 minutes before realizing the problem already existed before I changed anything. Anyway, as to this concept, simply overlaying the button would look something like this (except proper of course): Interestingly, I didn't realize that that final space already seems to be unused. Trying to put a character there switches the display. That means I took an overly complicated approach to solve a problem that didn't quite exist.
Mind, the patch to switch to overlap is only a few lines so no effort wasted as long as this button concept is used: diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua
index a69413d83..bb4341fa1 100644
--- a/frontend/ui/widget/inputtext.lua
+++ b/frontend/ui/widget/inputtext.lua
@@ -11,6 +11,7 @@ local HorizontalSpan = require("ui/widget/horizontalspan")
local IconButton = require("ui/widget/iconbutton")
local InputContainer = require("ui/widget/container/inputcontainer")
local Notification = require("ui/widget/notification")
+local OverlapGroup = require("ui/widget/overlapgroup")
local ScrollTextWidget = require("ui/widget/scrolltextwidget")
local Size = require("ui/size")
local TextBoxWidget = require("ui/widget/textboxwidget")
@@ -554,9 +555,6 @@ function InputText:initTextBox(text, char_added)
end
local text_width = self.width
- if text_width and show_keyboard_button then
- text_width = math.max(0, text_width - keyboard_button_width)
- end
if not self.height then
-- If no height provided, measure the text widget height
@@ -640,10 +638,9 @@ function InputText:initTextBox(text, char_added)
}
local input_row
if show_keyboard_button then
- input_row = HorizontalGroup:new{
- align = "center",
+ self._frame_keyboard_button.overlap_align = "right"
+ input_row = OverlapGroup:new{
self._frame_textwidget,
- HorizontalSpan:new{ width = keyboard_button_spacing },
self._frame_keyboard_button,
}
elseIn the text editor that would look like this:
Here too it seems characters don't actually want to go in that space.
|
It's either because wrapping (try to input i + space + i + space), or because there's some area on the right reserved for the scrollbar (which is not shown until needed). |
Yes, it seems an extra-thin character can indeed be hidden by this concept in this general form.
It's just a generic multiline textinput. The only reason I used that particular one to take a screenshot is because you keep talking about it. 😄 |
|
Oops, I didn't intend to post any of that here. That was meant for #15051. |
This button has no effect when VK disabled - while Shift+Home works and displays the VK (but over these buttons, without adjusting the geometry like this button used to do (and does on Touch devices). @Commodore64user : can you have a quick look at koreader/frontend/ui/widget/inputdialog.lua Lines 928 to 939 in 80cb27d but you haven't touched InputDialog:toggleKeyboard() at all - so just hoping you might have forgotten an obvious bit .
|
|
@poire-z not a fix but a start, maybe you can think about it as well... diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua
index fd5baa402..1785c5272 100644
--- a/frontend/ui/widget/inputdialog.lua
+++ b/frontend/ui/widget/inputdialog.lua
@@ -198,6 +198,7 @@ local InputDialog = FocusManager:extend{
_buttons_scroll_callback = nil,
_buttons_backup_done = false,
_buttons_backup = nil,
+ _vk_startup_skip_done = false,
}
function InputDialog:init()
@@ -223,9 +224,11 @@ function InputDialog:init()
if self.fullscreen or self.add_nav_bar then
self.deny_keyboard_hiding = true
end
- if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then
+ if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled")
+ and not self._vk_startup_skip_done then
self.keyboard_visible = false
self.skip_first_show_keyboard = true
+ self._vk_startup_skip_done = true
end
-- Title & description |
|
Looks like it just work :) (haven't looked why). |
The caveats? It doesn't work properly, use the keyboard to toggle it. |
…loop (koreader#15055) Due to the way this was wired, koreader#14937 trigged BookStatusWidget:onSwitchFocus() when closing, which caused the review input dialog to pop right back up again. But it doesn't look like you're actually supposed to be able to type in there at all, so I replaced it with a TextBoxWidget.









what's fixed
initTouchEvents()ininputtext.luato better handle when to show the virtual keyboard, start text input, and manage focus flags, particularly when a physical keyboard or DPad is present. This includes ensuring correct visual focus updates on DPad devices and avoiding unnecessary reinitialization of the input field.virtualkeyboard.lua, set the initial focus to the "Enter" key when the virtual keyboard is displayed on devices with a physical keyboard, making it easier to introduce new lines.UIManager:close()with a call to the parent'sonCloseDialog()method, allowing for more flexible and consistent dialog management.related issues
This change is