TextEditor and ScrollBar customisation


#1

I just noticed that there is no way to set the TextEditor’s vertical ScrollBar’s colour id’s, or just the thumb colour is really what I’m looking for.


#2

You can override these methods implemented in LookAndFeel and implement your version of the scrollbar look and feel.


#3

I have my own LookAndFeel class…
I need to change the thumb colour of the scroll-bar in one of my text editors. Usually Jules would provide a getScrollBar() method to get access to these types of internals e.g. ListBox::getVerticalScrollBar()

If the scroll-bar is there then one would like the option to utilize the ScrollBar::ColourIds no?


#4

getViewport() would be nice…


#5

If you set a custom look and feel for the texteditor, it’ll be inherited by the scrollbar, so should do what you need, shoudn’t it?


#6

Please correct me if am wrong, Are you trying to create a separate look for only few scroll bar.

This code should give you access to the view port.

_pViewPort	= dynamic_cast<juce::Viewport*>(_pEditor->getChildComponent (0));					

But I am not very sure, how helpful it could be.


#7

jules
So I have to make a separate look and feel just to get a different thumb colour for just one of my text editors.

vishvesh
That would work, but if the child hierarchy changes in the future (for some bizarre reason) it would break. I guess I can iterate through all the children and make sure that the pointer I’m grabbing is in fact a view- port. (Safer this way).


#8

Well yes… You don’t need to write a new class, you can just use a LookAndFeel object and change its colours. It’s only a couple of lines of code.


#9

Yes.

I was working with a shared l&f object, and changing the colour with setColour (ScrollBar::thumbColourId, Colours::blue); would change all my scroll bars… So I’ll make another instance for the editor that needs the special colour. Great.

Just out of curiosity, why does ListBox have ListBox::getVerticalScrollBar and ListBox::getHorizontalScrollBar

I know it says:

[quote]Returns a pointer to the scrollbar.

(Unlikely to be useful for most people).[/quote]


#10

[quote]Just out of curiosity, why does ListBox have
Code:
ListBox::getVerticalScrollBar
and
Code:
ListBox::getHorizontalScrollBar
[/quote]

Just in case you need to do stuff like setting the scroll increments, etc.