Skip to content
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

selection and cursor pos #258

Open
wants to merge 9 commits into
base: rich_input_update
Choose a base branch
from

Conversation

Sublustris
Copy link

Need some help in rich_input.lua - line 186

@Sublustris
Copy link
Author

That's all the features we want to add this time, please let us know when you would be ready with code review. If something needs fixes, let us know too pls.

@Insality Insality changed the base branch from master to develop March 18, 2024 21:51
Copy link
Owner

@Insality Insality left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

Let's first fix all UX things, like more accurate selection and input handling (currently the rich input consumes all the input)

@@ -91,6 +91,7 @@ end
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
-- @tfield[opt=false] bool IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input
-- @tfield[opt=false] bool NO_CONSUME_INPUT_WHILE_SELECTED If true, will not consume input while input is selected. It's allow to interact with other components while input is selected (text input still captured)
-- @tfield[opt=false] bool SKIP_INPUT_KEYS If true, input component will skip processing keys input allowing to process it completely in other components
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should escape the changing input process order from the components

}


local function set_cursor(self)
if self.touch_pos_x then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the touch_pos_x should be as arg of function, wdyt?

self.input.style.NO_CONSUME_INPUT_WHILE_SELECTED = true
self.input.style.SKIP_INPUT_KEYS = true

self.input.cursor_letter_index = 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already inited in input component

local gap = self.input.total_width/2 * -1

for i = 1, letters_count do
cursor_delta = gap + self.text:get_text_size(string.sub(text, 1, i)) - self.half_cursor_width
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like half_cursor_width can be removed, I rely on this video

Screen.Recording.2024-03-18.at.15.32.56.mov


self.input.button.on_click:subscribe(on_button_click, self)
self.input.button.on_double_click:subscribe(on_button_double_click, self)
self.input.style.NO_CONSUME_INPUT_WHILE_SELECTED = true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the rich input should not change these style settings (and for skip input keys same)

gui.set_position(self.cursor, vmath.vector3(self.input.total_width/2, 0, 0))
self.input.cursor_letter_index = 1
else
gui.set_position(self.cursor, vmath.vector3(0, 0, 0))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a local TEMP_VECTOR = vector3(0) in module scope, change their fields instead creating vector each time. It allows to save a bit of memory

@@ -92,4 +172,55 @@ function RichInput.set_placeholder(self, placeholder_text)
end


function RichInput.on_input(self, action_id, action)
self.action_pos_x = action.screen_x
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values action_pos_x and touch_pos_x should not be stored in rich input component. You can use it as a local variables inside only on_input functions

end

if action_id == const.ACTION_TEXT then
--self.input.cursor_letter_index = self.input.cursor_letter_index +1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty if + comments

@@ -219,10 +228,12 @@ function Input.on_input(self, action_id, action)

if input_text or #self.marked_value > 0 then
self:set_text(input_text)
return true
--return true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a mistake

@Insality Insality mentioned this pull request Mar 21, 2024
@Insality Insality changed the base branch from develop to rich_input_update March 21, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants