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

Support moving the text cursor on textboxes #13

Open
ericoporto opened this issue Feb 16, 2021 · 2 comments
Open

Support moving the text cursor on textboxes #13

ericoporto opened this issue Feb 16, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@ericoporto
Copy link
Owner

This was done in mierenhoop/microui@fd120b6

May be interesting to replicate here and see if it works!

@ericoporto
Copy link
Owner Author

ericoporto commented Feb 16, 2021

This code is not exactly production ready actually so it may require more experiments

I played around a bit and got something more or less

    /* handle text input */
    int len = buf.Length;
    int n = _min(bufsz - len - 1,  this.input_text.Length);
    if(n > 0)
    {
      String before_cur = buf.Substring(0, this.input_cursor);
      String after_cur = buf.Substring(this.input_cursor, buf.Length - this.input_cursor);
      before_cur = before_cur.Append(this.input_text.Truncate(n));
      buf = before_cur;
      buf = buf.Append(after_cur);
      res.state = res.state | eImGi_Res_Change;
    }

Still need to think more before doing this. I think Snarky has this working in AGS Script somewhere that I could take a look and see how he accomplished it.

@ericoporto
Copy link
Owner Author

Snarky has a very useful implementation for AGS going on here:
https://github.com/messengerbag/TextField/blob/master/TextField.asc

There are probably useful things I could borrow - adapting for ImGi needs.

@ericoporto ericoporto added the enhancement New feature or request label Feb 19, 2021
@ericoporto ericoporto changed the title Enhancement: support moving the text cursor on textboxes Support moving the text cursor on textboxes Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant