# Viewport & custom scrollBars

**URL:** <https://forum.juce.com/t/viewport-custom-scrollbars/24302>\
**Category:** General JUCE discussion\
**Created:** [September 21, 2017, 2:36pm UTC](https://forum.juce.com/t/viewport-custom-scrollbars/24302 "2017-09-21T14:36:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [September 21, 2017, 2:36pm UTC](https://forum.juce.com/t/viewport-custom-scrollbars/24302/1 "2017-09-21T14:36:00Z")

</div>

Could we get a virtual method added to Viewport that would be called to create each scrollbar :

`virtual ScrollBar* createScrollBarComponent (bool isVertical);`

That would allow us to set up custom scrollbars (for more than simple lnf tweaks) through subclassing.  
edit: fixed typo in the patch  
[patch.txt](https://forum.juce.com/uploads/short-url/3xK55pTxjaZF98kajYS8KbfAxFK.txt) (8,8 Ko)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 25, 2017, 9:09am UTC](https://forum.juce.com/t/viewport-custom-scrollbars/24302/2 "2017-09-25T09:09:49Z")

</div>

Seems like a sensible request, I’ll sort that out, ta.

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [October 5, 2017, 4:09pm UTC](https://forum.juce.com/t/viewport-custom-scrollbars/24302/3 "2017-10-05T16:09:58Z")

</div>

I left a comment here: [https://github.com/WeAreROLI/JUCE/commit/a4f5663fce97d8daec83df32bc67425dcb1bffe7#diff-0ba8ab46554278b8271142f3517b9790](https://github.com/WeAreROLI/JUCE/commit/a4f5663fce97d8daec83df32bc67425dcb1bffe7#diff-0ba8ab46554278b8271142f3517b9790)  
but I’m not sure if that will reach the right people…

Here it is for visibility:

I can’t see how this is going to work if createScrollBarComponent is called during the constructor as derived classes won’t have been constructed yet so it can’t call any overridden method. It always calls Viewport::createScrollBarComponent.

Perhaps we need a refreshScrollbars method or similar?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 6, 2017, 10:34am UTC](https://forum.juce.com/t/viewport-custom-scrollbars/24302/4 "2017-10-06T10:34:04Z")

</div>

hmm, good point, I’ll take a look.
