java - Adding Libgdx Scrollbar to TextArea -
so i've been searching around , life of cannot figure out how correctly this. have small text area , want able scroll through it. i've been told it's easy adding textarea scrollpane, appears more complicated that. here's gist of code:
skin defaultskin = newskin(default_skin_filepath +"uiskin.atlas", default_skin_filepath +"uiskin.json"); textarea textarea = new textarea(levelloader.getcodesnippet(), defaultskin); scrollpane pane = new scrollpane(textarea, defaultskin); pane.setforcescroll(false, true); pane.setflickscroll(false); pane.setoverscroll(false, true); pane.setbounds(0f, 20f, game.getwindowwidth(), 300f); gui.addactor(pane); gdx.input.setinputprocessor(gui); setiscreated(true);
levelloader.getcodesnippet() returns string containing multi-line piece of text .txt. textarea appears in game window, , multi-lined text appears. however, can scroll through text arrow keys. forced scrollbar display itself, occupies entire right side of window this: http://s27.postimg.org/vqws36k77/pic.png not scroll , thinks there not multiple lines scroll through though there evident scrolling through arrow keys. i've tried making textarea larger scrollpane, might have done incorrectly. doing wrong here?
update: i've tried both placing scrollpane inside of table , setting cell size of table. other suggestions appreciated.
this not best solution. guess libgdx update layout bug. workaround solution works me:
set pref. rows manually , update scroll layout, when number of rows changed.
textarea.setprefrows(numberofscrolllines); //numberofscrolllines = text.split("\n").length pane.layout();
Comments
Post a Comment