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

Crash when trying to select in VisTextArea when libGDX color marckup is enabled #348

Closed
fgnm opened this issue Dec 30, 2020 · 3 comments
Closed

Comments

@fgnm
Copy link
Contributor

fgnm commented Dec 30, 2020

VisTextArea and all its children (HighlightTextArea, ScrollableTextArea), crashes when color markup is enabled.

Stacktrace:

java.lang.IndexOutOfBoundsException: index can't be >= size: 1299 >= 1291
	at com.badlogic.gdx.utils.FloatArray.get(FloatArray.java:131)
	at com.kotcrab.vis.ui.widget.VisTextArea.drawSelection(VisTextArea.java:251)
	at com.kotcrab.vis.ui.widget.VisTextField.draw(VisTextField.java:350)
	at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:111)
	at com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.draw(ScrollPane.java:543)
	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:126)
	at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:111)
	at com.badlogic.gdx.scenes.scene2d.ui.Table.draw(Table.java:117)
	at com.badlogic.gdx.scenes.scene2d.ui.Window.draw(Window.java:253)
	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)

I think that start and end are not aware that markup glyphs are not rendered, and so the range is higher then the size of glyphPositions array

int start = Math.max(linesBreak.get(i), minIndex);
int end = Math.min(linesBreak.get(i + 1), maxIndex);

Where could be the right place to fix this? Thanks

@kotcrab
Copy link
Owner

kotcrab commented Dec 30, 2020

LibGDX and VisUI doesn't support color markup for any text field iirc, see #313.
Can you reproduce this with libgdx's TextArea?

@kotcrab kotcrab added the ui label Dec 30, 2020
@fgnm
Copy link
Contributor Author

fgnm commented Dec 31, 2020

TextArea don't work at all, I've got an empty rendering, while VisTextArea works overall well, it's broken just the selection, this is a screen of a VisTextArea rendering color markup string
immagine

It's a pity that VisUI does not support color markup just for this selection issue 😃

@kotcrab
Copy link
Owner

kotcrab commented Dec 31, 2020

VisTextArea is mostly a copy of TextArea so something must have changed. I remember it working in TextArea (or TextField?) with issues.
I'm guessing fixing this requires parsing the text to remove color markup before it's used for selection and others functions. I'd nice if this was working in libGDX, I never wanted to change VisTextArea too much.

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

No branches or pull requests

2 participants