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

Fix nk_edit_string cursor #57

Merged
merged 1 commit into from
Jan 9, 2024
Merged

Conversation

mhcerri
Copy link
Contributor

@mhcerri mhcerri commented Jan 9, 2024

RayLib seems to only measure the spacing between glyphs:

https://github.com/raysan5/raylib/blob/master/src/rtext.c#L1295

While Nuklear iterates over each glyph from the edit_string when trying to calculate the cursor position calling the width function for each char of the input:

https://github.com/vurtun/nuklear/blob/master/src/nuklear_util.c#L1105

That means we need to add one additional spacing when returning the width to compensate for the missing spacing from RayLib.

Closes #53

RayLib seems to only measure the spacing *between* glyphs:

https://github.com/raysan5/raylib/blob/master/src/rtext.c#L1295

While Nuklear iterates over each glyph from the edit_string when
trying to calculate the cursor position calling the width function for
each char of the input:

https://github.com/vurtun/nuklear/blob/master/src/nuklear_util.c#L1105

That means we need to add one additional spacing when returning the
width to compensate for the missing spacing from RayLib.
@RobLoach
Copy link
Owner

RobLoach commented Jan 9, 2024

Thanks a lot for these fixes.

@RobLoach RobLoach merged commit 06d53da into RobLoach:master Jan 9, 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.

nk_edit_strings displays incorrectly
2 participants