[InputText, DictQuickLookup] Shortcuts for NT kindle#12078
Conversation
|
Please don't tack on random button swaps. |
Yes, it has some kind of logic: #7511 (comment) |
|
It is not random, when you edit a string, say "reluctantly" to "reluctant" you need to press twice as many keys to perform the new dic lookup. Having it like this reduces the presses from 4 to 2, (from |
|
This is a seemingly innocent PR that randomly tacks on unrelated changes. I borderline merged it before noticing this unwelcome stowaway. |
Are we still talking about the swap? Is not unrelated, didn't i just explain the reasoning? |
|
You did, but in the attempt to make it easier for NT users, you make it unnatural and less easy for right handed touch devices users. |
|
I can revert it if a patch is offered in return... deal or no deal? |
No deal. Feel free to submit another PR that doesn't hijack the menu order. |
|
Wtf man? Why do you have to act in such a 'tyrannical' way when i just said i am going to put it back (later when i get time to sit in front of my computer), only i am not allowed to ask @poire-z directly for help with patches so i have to make it open to all, playful and silly. |
|
I put some boundaries. That's always received as 'tyrannical'. I have no problem with that!
That's explicit. You could have used something like: "Alright, I'll change this to the original button placement!. Is there a way to swap them using a patch?" But your answers don't imply that ¿? "Are we still talking about the swap? Is not unrelated, didn't i just explain the reasoning?"
I usually have no problem with playful and silly comments. Yours is something else. You're addressing reviewers that asked you to change your PR. "Deal or no deal?" I addressed that, with no deal. |
I don't think you aren't :) (I remember I mentionned once I would not help you as long as you discussed the thing in the horrible GitHub Discussions, but I had since helped you.) To prove you wrong: diff --git a/frontend/ui/widget/buttontable.lua b/frontend/ui/widget/buttontable.lua
index 4b50795b..4f1131ae 100644
--- a/frontend/ui/widget/buttontable.lua
+++ b/frontend/ui/widget/buttontable.lua
@@ -45,7 +45,10 @@ function ButtonTable:init()
local table_min_needed_width = -1
for i = 1, row_cnt do
self:addVerticalSpan()
- local buttons_layout_line = {}
+ -- All (not all?) button tables layout are aimed at right handed people, with most useful
+ -- and less risky buttons on the right. Make this available to Non-Touch devices too by
+ -- entering vertically merged buttontables items on the right
+ local buttons_layout_line = { gravity = "right" }
local horizontal_group = HorizontalGroup:new{}
local row = self.buttons[i]
local column_cnt = #row
diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua
index c5f8ad53..11b5c604 100644
--- a/frontend/ui/widget/dictquicklookup.lua
+++ b/frontend/ui/widget/dictquicklookup.lua
@@ -723,6 +723,7 @@ function DictQuickLookup:init()
if Device:hasDPad() then
table.insert(self.button_table.layout, 1, { self.dict_title.left_button });
table.insert(self.button_table.layout, 2, { lookup_edit_button });
+ self.button_table:refocusWidget(false, true)
end
-- We're a new window
diff --git a/frontend/ui/widget/focusmanager.lua b/frontend/ui/widget/focusmanager.lua
index abb33089..343dadce 100644
--- a/frontend/ui/widget/focusmanager.lua
+++ b/frontend/ui/widget/focusmanager.lua
@@ -223,6 +223,7 @@ function FocusManager:onFocusMove(args)
return true
end
local current_item = self.layout[self.selected.y][self.selected.x]
+ local current_gravity = self.layout[self.selected.y].gravity
while true do
if not self.layout[self.selected.y + dy] then
--horizontal border, try to wraparound
@@ -244,6 +245,12 @@ function FocusManager:onFocusMove(args)
self.selected.x = self.selected.x + dx
end
logger.dbg("FocusManager cursor position is:", self.selected.x, ",", self.selected.y)
+ if self.layout[self.selected.y].gravity ~= current_gravity and dx == 0 then
+ if self.layout[self.selected.y].gravity == "right" then
+ -- We're moving up/down, and meeting a row with gravity=right: focus on the right most item
+ self.selected.x = #self.layout[self.selected.y]
+ end
+ end
if self.layout[self.selected.y][self.selected.x] ~= current_item
or not self.layout[self.selected.y][self.selected.x].is_inactive then
@@ -472,8 +479,18 @@ FocusManager.RENDER_IN_NEXT_TICK = true
--- Container calls this method to re-set focus widget style
--- Some container regenerate layout on update and lose focus style
-function FocusManager:refocusWidget(nextTick)
+function FocusManager:refocusWidget(nextTick, force_reset)
if not self._parent then
+ if force_reset then
+ self.selected.x = 1
+ self.selected.y = 1
+ self._gravity_refocused = nil
+ end
+ if not self._gravity_refocused and self.layout and self.layout[self.selected.y].gravity == "right" then
+ -- This is used by ButtonTable: initially focus on the right most item
+ self.selected.x = #self.layout[self.selected.y]
+ self._gravity_refocused = true
+ end
if not nextTick then
self:moveFocusTo(self.selected.x, self.selected.y)
elseThis was my initial idea:
|
|
No man, you could have easily requested changes via a code review and that would have been "setting boundaries". Also, even thought i indirectly indicated that i would change them back, you didn't give me enough time (and notice) to do so. I have been busy and have not had time to use a computer all day. Perhaps my message was bad at conveying that, but your actions were a lot worse. One more thing "deal or no deal" is a British show based on a famous dutch one, which i thought perhaps @Frenzie would have appreciated if he had gotten the reference (long shot though) |
|
I didn't catch the reference, no. But @pazos did make me smile. Don't serve it if you can't dish it. ^_^ |
|
The same, "simple" place swap (translate for dictionary) but on patch form should be enough really. No need to change how anything else functions. I appreciate your help @poire-z, i really do. |
|
You mean/meant "user patch" all along ?! :/ Well, there's no real possibility to hijack the function and just swap them at the end, but you can just replace the whole function with a copy of the original with the buttons swapped, it's not a function we change often. local DictQuickLookup = require("ui/widget/dictquicklookup")
-- all the other local xyz=require for all the things used in the function, ie.
local InputDialog = require("ui/widget/inputdialog")
local UIManager = require("ui/uimanager")
DictQuickLookup.lookupInputWord = function(self, hint)
-- copy of the original one, and modify it as you wish
end |
yes, i just don’t think that changing how the focus normally works is a better approach. It is okay though, i just might be the only person that cares anyway and unlike what some people stated, it was never intended as a hijack. If i had known it would bring the worst in some people i would not have committed it. anyway, back to bedlam now. (This is a joke btw) |
| self:downLine() | ||
| elseif key["End"] then | ||
| self:goToEnd() | ||
| elseif key["Home"] then |
There was a problem hiding this comment.
Explain? We'll have to find a different way of doing whatever you're trying to do here.
There was a problem hiding this comment.
That is freeing the home button for a [hopefully] future global event that takes you to the FM.
There was a problem hiding this comment.
Please don't tack on random changes in behavior either, especially not for "the future".
There was a problem hiding this comment.
Also no: here, we are editing text, keep the symetry Home/End to go to start/end.
No reason to have Home here taking you to FM.
There was a problem hiding this comment.
I just want to add that this home/end thing is only true for actual keyboards. On kindle there is no “end” key so… no symmetry there
and to counter the “no reason to have you take to the fm” that is the job of a home button though, wherever you are it should always take you home.
| if key["Backspace"] then | ||
| self:delChar() | ||
| elseif key["Del"] then | ||
| self:delNextChar() | ||
| self:delChar() |
There was a problem hiding this comment.
This affects the emulator, when using a real keyboard. On PCs, backspace remove the previous char, Del/Suppr remove the next char. No reason to change that behaviour.
There was a problem hiding this comment.
Kindle has a “del” key only, no backspace. Which means you can’t delete with the delete key.
There was a problem hiding this comment.
would this be better ...
if Device:hasSymKey() then
if key["Del"] then
self:delChar()
end
else
if key["Del"] then
self:delNextChar()
end
endThere was a problem hiding this comment.
Not Device:hasScreenKB() or Device:hasSymKey()?
There was a problem hiding this comment.
no delete key on k4 so the first bit (hasScreenKB) is unnecessary, that is why I am using ScreenKB + Back as delete there
|
thought about adding to kindle something like if key["Shift"] then
if key["."] then
self:addChars(",")
end
end
so if one hides the keyboard, one can still type [regular] sentences without needing to bring up the VK, but I end up adding |
| if not key["Ctrl"] and not key["Shift"] and not key["Alt"] and not key["ScreenKB"] then | ||
| if key["Backspace"] then | ||
| self:delChar() | ||
| elseif key["Del"] then | ||
| self:delNextChar() |
There was a problem hiding this comment.
I think the handling of Del should be kept here, under the same conditions as the other ones (no Ctrl, no Shift, no Alt...).
I see no reason to make it generically a special case without these conditions below.
There was a problem hiding this comment.
mmm, but it would still affect the kindle then. I could add all the conditions to the new else if you prefer
There was a problem hiding this comment.
Can't you just overwrite it later if hasSymKey?
There was a problem hiding this comment.
Ah never mind, this is in a handling function, not assigning something. But why not simply handle it here?
There was a problem hiding this comment.
Just add your kindle conditions in there:
if not key["Ctrl"] and not key["Shift"] and not key["Alt"] and not key["ScreenKB"] then
if key["Backspace"] then
self:delChar()
elseif key["Del"] then
if iskindlecrap then -- and write why we do that
self:delChar()
else
self:delNextChar()
end
elseif...
If you don't try, or give feedback about, my suggestions, I guess I won't bother investigating that one with you. |
apologies, I think I must have misread your message cause I thought you were saying find the other bit and add it there elseif key["."] then
self:addChars(",")
return truethat works fine |
| elseif key["."] then | ||
| if Device:hasSymKey() then | ||
| self:addChars(",") | ||
| return true |
There was a problem hiding this comment.
It is not because it works that it should go in - my suggestion was just for testing and seeing if there was a "later".
Now, you should make it cleaner - similar to the existing code you inserted that bit in the middle.
if not handled and (key["ScreenKB"] or key["Shift"]) then
handled = true
if .... then
elseif ... then
else
handled = false
end
end
if not handled and Device:hasDPad() thenThere was a problem hiding this comment.
it's missing my parens in x and (y or z).
There was a problem hiding this comment.
Keep it still as previous ones: there is no "return true" in them. you just need a handled=false in the else branch.
|
Unrelated to this PR as it happens with or without, just adding a note to remember: When in some text box (ie. adding a note for a long highlight), hitting the Home key keep moving to the start of the previous line (dunno if that is the behaviour we expected ? feels like we shouldn't move anymore when we are at the start of line), when reaching the first line and hitting Home again, it crashes with: |
| if not handled and (key["ScreenKB"] or key["Shift"]) then | ||
| handled = true | ||
| if key["Back"] then | ||
| self:delChar() | ||
| elseif key["Left"] then | ||
| self:leftChar() |
There was a problem hiding this comment.
So, in effect, this makes all these keys work as-is when you are still holding Shift pressed, which I guess is practical and fine by me.
Except for Home and End - but ok. But we're hacking Shift+Home to hide/show keyboard, so preventing further implementations of something balanced. Just mentionning that.
About Shift + . outputing a comma, I checked that (with another key, as my keyboard does not have the dot available as a plain key) that it seems there is no impact, and we would never get that comma with a real keyboard on the emulator. Not sure why :) and how Shift is handled.
I checked with the virtucal keyboard, by putting . in both the first panel and the panel we get when we press Shift, and I keep getting .. Good. (But of course, it is wrapped bt hasSymKeys().... realized that too late).
There was a problem hiding this comment.
that it seems there is no impact, and we would never get that comma with a real keyboard on the emulator. Not sure why :)
SDL gives us a full string so we don't have to worry about any of the complexities involved in a keypress not mapping directly to a character. (like for typing é)
There was a problem hiding this comment.
So the TL;DR here is, all good, right?
as my keyboard does not have the dot available as a plain key
wild. Buy a better keyboard ;)
btw, tested now, working as expected.
|
Let's not add that here but, do we know why the "Alt" thing won't work then... #12078 (comment) |
Instead of copy/paste existing code in comments, and needing us to figure out where it comes from to get more context, you can use: koreader/frontend/ui/widget/inputtext.lua Lines 656 to 660 in 0ae8464
Dunno :) This snippet is later, so probably not. |
|
First and foremost, this is done here so, do your thing @Frenzie ...
I am familiar with that, it was just too late and could not be bothered. Easier to copy and paste. my bad.
even mr fancy pants over here does not work: if Device:hasSymKey() then
if not handled and key["Alt"] then
handled = true
if key["Q"] then
self:addChars("1")
elseif key["W"] then
self:addChars("2")
elseif key["E"] then
self:addChars("3")
elseif key["R"] then
self:addChars("4")
elseif key["T"] then
self:addChars("5")
elseif key["Y"] then
self:addChars("6")
elseif key["U"] then
self:addChars("7")
elseif key["I"] then
self:addChars("8")
elseif key["O"] then
self:addChars("9")
elseif key["P"] then
self:addChars("0")
else
handled = false
end
end
endso there is something blocking it "somewhere only we [don't] know" (any Keane fans?) |
|
You say it's not working yet? |
The PR as is right now works fine, what doesn't work is the "alt" + "top row keys" to get numerical values. But that is not included here [yet] and could be add it later. |
… toggle virtual keyboard, comma on shift+. (koreader#12078)
… toggle virtual keyboard, comma on shift+. (koreader#12078)

Yet another PR that slightly improves use on NT kindles.
When a NT user selects a word for which their dictionary might either show a tautological definition or some variation of "alternative spelling", said user can now go to edit mode (as meta-lookup is not available on NT) and quickly make changes with shortcuts. For example: A user searching for the word "caftan" on Wiktionary will get "Alternative spelling of kaftan", selecting edit and with this PR, said user is allowed to make the required adjustments much, much faster than by simply relying on the virtual keyboard.
Also, added a shortcut to toggle the VK without losing focus
Shift+Home(ScreenKB+Home, not sure why anyone would want to do it on K4 nonetheless here it is). As seen here #11374 (not sure if this PR should close that ticket as it is kind of a workaround rather than a full working setting, let me know)This change is