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

Added methods to get/set/move the cursor in Editbox and InputText #789

Closed
wants to merge 3 commits into from

Conversation

yui-915
Copy link
Contributor

@yui-915 yui-915 commented Sep 4, 2024

pushing text to the string buffer doesn't update the cursor's position, added methods to get/set it manually when needed.

I have a few questions:

  • should the methods be rename to something like get_cursor_pos or get_cursor_position ?
  • currently the take &mut Ui as an argument, is it okay to remove it and call root_ui instead ?
  • should calling the set/move method effect the EditboxState's selection and/or redo_stack/undo_stack ?
  • currently using saturating_add and saturating_sub to prevent underflow and overflow (unlikely to happen), should it just do += and allow underflows ?
  • the code in TextInput is the same as Editbox, should it construct a new Editbox and call it's methods instead ? like this
pub fn move_cursor(&self, ui: &mut Ui, amount: i32) {
    Editbox::new(self.id, vec2(0., 0.)).move_cursor(ui, amount)
}

@yui-915 yui-915 closed this by deleting the head repository Nov 6, 2024
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.

1 participant