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

Textarea bug when a line is preceded by new line #336

Closed
fgnm opened this issue Aug 29, 2020 · 5 comments
Closed

Textarea bug when a line is preceded by new line #336

fgnm opened this issue Aug 29, 2020 · 5 comments
Labels

Comments

@fgnm
Copy link
Contributor

fgnm commented Aug 29, 2020

I've create a very simple textarea without any special stuff:

VisTextArea textArea = new VisTextArea("");
getContentTable().add(textArea).grow();

textarea_bug

But I've a strange bug when I start typing after a new line. As you can see from the GIF, the cursor does not arrives at the end of the line, this is not just a visual bug, but causes also many crashes of that kind during selection or clicks in the textarea.

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 28 out of bounds for length 28
	at com.kotcrab.vis.ui.widget.VisTextField.calculateOffsets(VisTextField.java:259)
	at com.kotcrab.vis.ui.widget.VisTextArea.calculateOffsets(VisTextArea.java:283)
	at com.kotcrab.vis.ui.widget.VisTextField.draw(VisTextField.java:347)
	at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:124)
	at com.badlogic.gdx.scenes.scene2d.Group.draw(Group.java:58)
	at com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.draw(WidgetGroup.java:170)
	at com.badlogic.gdx.scenes.scene2d.ui.Table.draw(Table.java:120)
	at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:111)
	at com.badlogic.gdx.scenes.scene2d.ui.Table.draw(Table.java:111)
	at com.badlogic.gdx.scenes.scene2d.ui.Window.draw(Window.java:252)
	at com.kotcrab.vis.ui.widget.VisWindow.draw(VisWindow.java:239)
	at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:111)
	at com.badlogic.gdx.scenes.scene2d.Group.draw(Group.java:58)
	at com.badlogic.gdx.scenes.scene2d.Stage.draw(Stage.java:129)

Or this

Caused by: java.lang.IndexOutOfBoundsException: index can't be >= size: 116 >= 114
	at com.badlogic.gdx.utils.FloatArray.get(FloatArray.java:131)
	at com.kotcrab.vis.ui.widget.VisTextArea.moveCursorLine(VisTextArea.java:164)
	at com.kotcrab.vis.ui.widget.VisTextArea$TextAreaListener.keyDown(VisTextArea.java:437)
	at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:53)
	at com.badlogic.gdx.scenes.scene2d.Actor.notify(Actor.java:188)
	... 10 more

I already use a mono spaced font generated from a TTF. Could you help me to identify the cause of that bug? Unfortunately, in test window I connot reproduce it.

@kotcrab
Copy link
Owner

kotcrab commented Aug 29, 2020

I'd recommend first trying it with libgdx's TextArea, maybe some fix wasn't ported.

@fgnm
Copy link
Contributor Author

fgnm commented Aug 29, 2020

Yes, I've tried with Scene2D's TextArea and same style I use for VisTextArea and this issue is not present, it works fine

@kotcrab
Copy link
Owner

kotcrab commented Aug 29, 2020

So fixing this requires syncing sources of VisTextField and VisTextArea with libgdx.

@fgnm
Copy link
Contributor Author

fgnm commented Aug 29, 2020

I've look at commits in libGDX and I've found that with this two the issue is fixed: libgdx/libgdx@c2d2313#diff-81602c9f8b4b94e2ec22c65427fbd35b and libgdx/libgdx@b0d8a2b#diff-81602c9f8b4b94e2ec22c65427fbd35b

There are also a lot of other commits that might be good (or not) for VisUI too, however I don't know if they may affects others VisTextField functionalities, so please let me know if you prefer a PR with that two changes or wait for a yours fix, thanks.

@kotcrab
Copy link
Owner

kotcrab commented Aug 29, 2020

Looks like you already figured it out. I'd prefer a PR with those two fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants