Hi,
i’m using the rex-ui slider component in my game (e.g. for the rex-ui Table / TextArea).
Is there any easy way to check if the slider is needed or not?
For example:
TextArea starts with a short text, no overlfow => hide slider
TextArea gets update with long text, overflow => show slider
TextArea gets update short text, no overflow => hide slider
How to check if slider can scroll or not?
i’ve tried this:
let txtEl = this.getElement("text");
this.getElement("slider").setVisible( txtEl.height > this.height );
But mny “txtEl” has allways the same height, regadless of the text i add.
For tables i extend the Rex-Table Class and overwrite the “setItems” method:
setItems( items ){
super.setItems( items );
let showScrollbar = this.items.length > this.getElement("table").visibleCells.entries.length;
if( this.items.length == 0 ) showScrollbar = false;
// check item overlapping
if( !showScrollbar && this.items.length > 1){
let lastItemBounds = this.getCellContainer( this.items.length -1 ).getBounds();
let tableBounds = this.getBottomLeft();
showScrollbar = lastItemBounds.y + lastItemBounds.height > tableBounds.y;
}
this.getElement("slider").setVisible( showScrollbar );
return this;
}
But i think there should be some easyer way or even an option on the rex-plugins like “showOnOverflow” or something like this
Greetings!
Puccini