You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When typing a text longer than the input box, when typing the last character, typically the cursor disappears, and one character is shown partially.
This is caused by the fact that the control box width is greater than the edit box width, and the former is used for text width calculations. The latter is adjusted in https://github.com/vrld/SUIT/blob/master/theme.lua#L105 to be 6 pixels less than the control's bounding box.
It would be trivial to fix it this way, but that would not cover the case where the theme is adjusted to set a different margin for the edit box:
diff --git a/input.lua b/input.lua
index e5861bd..0751f40 100644
--- a/input.lua+++ b/input.lua@@ -15,7 +15,7 @@ return function(core, input, ...)
opt.font = opt.font or love.graphics.getFont()
local text_width = opt.font:getWidth(input.text)
- w = w or text_width + 4+ w = w or text_width + 6
h = h or opt.font:getHeight() + 4
input.text = input.text or ""
@@ -29,23 +29,24 @@ return function(core, input, ...)
-- get size of text and cursor position
opt.cursor_pos = 0
if input.cursor > 1 then
- local s = input.text:sub(0, utf8.offset(input.text, input.cursor)-1)+ local s = input.text:sub(1, utf8.offset(input.text, input.cursor)-1)
opt.cursor_pos = opt.font:getWidth(s)
end
-- compute drawing offset
+ local wm = w - 6 -- consider margin
input.text_draw_offset = input.text_draw_offset or 0
if opt.cursor_pos - input.text_draw_offset < 0 then
-- cursor left of input box
input.text_draw_offset = opt.cursor_pos
end
- if opt.cursor_pos - input.text_draw_offset > w then+ if opt.cursor_pos - input.text_draw_offset > wm then
-- cursor right of input box
- input.text_draw_offset = opt.cursor_pos - w+ input.text_draw_offset = opt.cursor_pos - wm
end
- if text_width - input.text_draw_offset < w and text_width > w then+ if text_width - input.text_draw_offset < wm and text_width > wm then
-- text bigger than input box, but does not fill it
- input.text_draw_offset = text_width - w+ input.text_draw_offset = text_width - wm
end
-- user interaction
The text was updated successfully, but these errors were encountered:
The question would be how to obtain that information from the theme. I guess it could be some kind of standard setting in the theme itself, that theme makers would have to set. Basically you have two nested boxes: the control container box and the clipped text input box. Let theme designers be aware of this, and let them adjust the margin for the contained box. Then make input.lua read the theme's setting to adjust the margins accordingly.
When typing a text longer than the input box, when typing the last character, typically the cursor disappears, and one character is shown partially.
This is caused by the fact that the control box width is greater than the edit box width, and the former is used for text width calculations. The latter is adjusted in https://github.com/vrld/SUIT/blob/master/theme.lua#L105 to be 6 pixels less than the control's bounding box.
It would be trivial to fix it this way, but that would not cover the case where the theme is adjusted to set a different margin for the edit box:
The text was updated successfully, but these errors were encountered: