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

Expose a version of textboxs caret_position method? #236

Open
Sigverus opened this issue Oct 17, 2020 · 2 comments
Open

Expose a version of textboxs caret_position method? #236

Sigverus opened this issue Oct 17, 2020 · 2 comments
Assignees

Comments

@Sigverus
Copy link

Can a function similar to caret_position be exposed as a public or protected method for textbox and possibly labels?


I'm rounding up some libraries for a personal project and been searching for one with the ability of causing "events" on words in either textbox and labels. This allows some tricks such as showing modals or footnotes when hovering the mouse over some words and other trickery. Looking into elements, I've noticed that the caret_position method seems to deduce the textbox's closest character to the mouse position and is very cleanly implemented. From there, the programmer can use this character position information with the text to implement actions.

Since I don't know much about the code, I'm assuming there might be a good reason for the function being implemented private (or maybe there's another way of obtaining this information and I'm missing the point)

@djowel djowel self-assigned this Oct 17, 2020
@djowel
Copy link
Collaborator

djowel commented Oct 17, 2020

It is not possible now due to the fact that the text box does not know its position (the position is in the context), but yes, it is doable with some API tweaks.

  1. I'm planning to provide a generic visit member function that setups and provides the correct context to a callback function.
  2. Expose the caret_position member function.
  3. In your visit callback, you can call caret_position with the proper context.

@djowel
Copy link
Collaborator

djowel commented Oct 17, 2020

I'm busy with some other tasks now, but if you can remind/ping me next week on Discord, I can make some time. This should not be difficult to add. We can do it in real time.

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

No branches or pull requests

2 participants