# Ableton Live-Style Text Slider

**URL:** <https://forum.juce.com/t/ableton-live-style-text-slider/26657>\
**Category:** General JUCE discussion\
**Created:** [March 6, 2018, 12:58am UTC](https://forum.juce.com/t/ableton-live-style-text-slider/26657 "2018-03-06T00:58:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ncthom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ncthom/32/3721_2.png) [@ncthom](https://forum.juce.com/u/ncthom)\
**Post date:** [March 6, 2018, 12:58am UTC](https://forum.juce.com/t/ableton-live-style-text-slider/26657/1 "2018-03-06T00:58:54Z")

</div>

In Ableton Live, one of the common slider styles looks like this:

![41%20PM](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/a/a0088b1a33dd857d23807f1cbb1583157ef357d9.png)

Clicking in the box and dragging vertically sets new values while the blue fill color fills left to right. Double-clicking lets you type in a value. I’m trying to make a slider like this in JUCE.

There’s already a `Slider::LinearBar` which is, visually, exactly the same thing, but it has a horizontal drag behavior. Similarly, `Slider::LinearBarVertical` is almost the same thing visually, but the fill color fills bottom to top instead of left to right and the drag direction is vertical.

I can get very close to a Live-style slider using `Slider::LinearBarVertical` and a custom LookAndFeel, but the drag behavior is confined to the height of the slider, which in this case is very small and makes for dialing in a value a terrible experience. It seems as well that `setMouseDragSensitivity` has no effect on this slider behavior. Am I missing something? Is there an easy way to increase the drag region for a slider like this?

---

<div class="post-metadata">

**Author:** ![jonathonracz](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jonathonracz](https://forum.juce.com/u/jonathonracz)\
**Post date:** [March 6, 2018, 3:51am UTC](https://forum.juce.com/t/ableton-live-style-text-slider/26657/2 "2018-03-06T03:51:03Z")

</div>

I coded this a few years ago because I wanted this exact same thing. I believe as a dirty hack I created a subclass of `Slider` where I overrode the mouse handler methods so the behavior was different, and changed the internal value directly.

In the end I actually created a completely new slider class of my own which separates interaction behavior from drawing entirely, and different methods of drawing, since they’re so drastically different (knob/draggable bar/linear bar) which ended up working out well.

Unfortunately IMO `Slider` is one of the weaker parts of the library because it has way too much stuff jammed into it - I wish it was more like `Button`. `Slider` is pretty much WYSIWYG when it comes to the interface, and if you want anything different you’ll have to hack differing behavior on by subclassing the giant monolithic class.

---

<div class="post-metadata">

**Author:** ![ttg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ttg/32/14456_2.png) [@ttg](https://forum.juce.com/u/ttg)\
**Post date:** [March 6, 2018, 10:44am UTC](https://forum.juce.com/t/ableton-live-style-text-slider/26657/3 "2018-03-06T10:44:10Z")

</div>

You can try go after mouse listeners of the slider, override them and transform the mouse Axis ([https://juce.com/doc/classMouseListener#a434a85e97e248920ae699a2f030bfa70](https://juce.com/doc/classMouseListener#a434a85e97e248920ae699a2f030bfa70))

---

<div class="post-metadata">

**Author:** ![tadnicol](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tadnicol/32/5141_2.png) [@tadnicol](https://forum.juce.com/u/tadnicol)\
**Post date:** [March 8, 2018, 8:19pm UTC](https://forum.juce.com/t/ableton-live-style-text-slider/26657/4 "2018-03-08T20:19:10Z")

</div>

This was the quickest fix for me (although I’m leaving out the horizontal blue element altogether):

```auto
s->setSliderStyle (Slider::SliderStyle::LinearBarVertical);
s->setColour (Slider::ColourIds::trackColourId, Colours::transparentWhite);
s->setVelocityBasedMode (true);
s->setVelocityModeParameters (0.4, 1, 0.09, false);

```

You can calibrate the feel of the sliding via the velocity mode parameters.
