HISE Docs

ScriptSlider


Class methods

addToMacroControl

Adds the knob / button to a macro controller (from 0 to 7).

ScriptSlider.addToMacroControl(int macroIndex)



changed

Call this to indicate that the value has changed (the onControl callback will be executed.

ScriptSlider.changed()



contains

Checks if the given value is within the range.

ScriptSlider.contains(double value)



createLocalLookAndFeel

Returns a local look and feel if it was registered before.

ScriptSlider.createLocalLookAndFeel()



createModifiers

Creates a object with constants for setModifiers().

ScriptSlider.createModifiers()


This creates an object holding constants to be used in setModifier() . There are two types of constants in there: action IDs and modifier key magic numbers.

Actions

There are multiple actions that are performed when interacting with a slider based on different modifier keys.

ID Default Description
TextInput shift key Opens the text input
ResetToDefault double click sets the slider to the default value
ContextMenu right click opens the context menu that lets you assign CCs etc
FineTune command, ctrl or alt changes the dragging sensitivity to a finer resolution

The constants for the Action IDs just hold the same string as value, so it's not 100% required to use them (however it let's you use the autocomplete entries instead of looking up the available actions).

Modifiers

The other constants in this object are modifier keys and are basically identical to the properties of the event JSON object that is passed into the mouse callback of the panel:

const var mods = Knob1.createModifiers();

// keyboard modifiers
mods.shiftDown
mods.altDown
mods.ctrlDown
mods.cmdDown

// mouse button modifiers
mods.rightClick
mods.doubleClick

// special modifiers
mods.disabled
mods.noKeyModifier

Be aware that these constants do not hold string values like the action IDs, but integer flags that use bitwise operators for combining multiple modifiers.

The special modifiers can be used to either disable an action altogether or make sure that the action is only performed if no modifier key is pressed (you will need that if you set two actions to the same mouse click type).


fadeComponent

Toggles the visibility and fades a component using the global animator.

ScriptSlider.fadeComponent(bool shouldBeVisible, int milliseconds)



get

returns the value of the property.

ScriptSlider.get(String propertyName)



getAllProperties

Returns a list of all property IDs as array.

ScriptSlider.getAllProperties()



getChildComponents

Returns list of component's children

ScriptSlider.getChildComponents()



getGlobalPositionX

Returns the absolute x-position relative to the interface.

ScriptSlider.getGlobalPositionX()



getGlobalPositionY

Returns the absolute y-position relative to the interface.

ScriptSlider.getGlobalPositionY()



getHeight

Returns the height of the component.

ScriptSlider.getHeight()



getId

Returns the ID of the component.

ScriptSlider.getId()



getLocalBounds

Returns a [x, y, w, h] array that was reduced by the given amount.

ScriptSlider.getLocalBounds(float reduceAmount)



getMaxValue

Returns the upper range end.

ScriptSlider.getMaxValue()



getMinValue

Returns the lower range end.

ScriptSlider.getMinValue()



getValue

Returns the current value.

ScriptSlider.getValue()



getValueNormalized

Returns the normalized value.

ScriptSlider.getValueNormalized()  override



getWidth

Returns the width of the component.

ScriptSlider.getWidth()



grabFocus

Call this method in order to grab the keyboard focus for this component.

ScriptSlider.grabFocus()



loseFocus

Call this method in order to give away the focus for this component.

ScriptSlider.loseFocus()



sendRepaintMessage

Manually sends a repaint message for the component.

ScriptSlider.sendRepaintMessage()



set

Sets the property.

ScriptSlider.set(String propertyName, var value)



setColour

sets the colour of the component (BG, IT1, IT2, TXT).

ScriptSlider.setColour(int colourId, int colourAs32bitHex)



setControlCallback

Pass a inline function for a custom callback event.

ScriptSlider.setControlCallback(var controlFunction)



setKeyPressCallback

Adds a callback to react on key presses (when this component is focused).

ScriptSlider.setKeyPressCallback(var keyboardFunction)



setLocalLookAndFeel

Attaches the local look and feel to this component.

ScriptSlider.setLocalLookAndFeel(var lafObject)



setMaxValue

Sets the upper range end to the given value.

ScriptSlider.setMaxValue(double max)



setMidPoint

Sets the value that is shown in the middle position.

ScriptSlider.setMidPoint(double valueForMidPoint)



setMinValue

Sets the lower range end to the given value.

ScriptSlider.setMinValue(double min)



setMode

Sets the knob to the specified mode.

ScriptSlider.setMode(String mode)



setModifiers

Sets the modifiers for different actions using a JSON object.

ScriptSlider.setModifiers(String action, var modifiers)


This allows you to override the default modifiers for various actions related to the slider. It expects an ID for the action you want to change and a combination of modifier keys that will be assigned to the action. For both parameters it's highly recommended to use the properties from the Modifier object returned by createModifiers() as it provides all available IDs and magic numbers as pretty named properties.

Be aware that this function is supposed to be called once at initialisation. Also it will keep the assignments from previous compilations, so if you want to reset it to the default you need to rebuild the UI from the interface designer.

Combining modifier keys

You can use both logical operators AND / OR in order to combine modifier keys, however the syntax differs a bit:

  1. The OR operator can be implemented using the bitwise-or syntax
  2. The AND operator must be implemented by passing an array of modifiers (up to three modifiers are supported)
const var mods = Knob1.createModifiers();

const var doubleClickAndShift = [ mods.doubleClick, mods.shiftDown];
const var rightClickOrAlt = mods.rightClick | mods.altDown;
const var commandOrShift = mods.shiftDown | mods.cmdDown;
const var doubleClickWithoutModifiers = [ mods.doubleClick, mods.noKeyModifiers ];

You can just overwrite the function you want to reassign, however you need to make sure that the assignment doesn't create any collision with the default mapping, otherwise the action that will be performed might not be the one you have reassigned (it will just pick the first match that is stored in a arbitrary order internally).

const var Knob1 = Content.getComponent("Knob1");
const var mods = Knob1.createModifiers();

// We want to reassign the reset double click to shift + double click
Knob1.setModifiers(mods.ResetToDefault, [ mods.doubleClick, mods.shiftDown ]);

// and the text input to a double click without modifiers.
Knob1.setModifiers(mods.TextInput, [mods.doubleClick, mods.noKeyModifier]);


setPosition

Sets the position of the component.

ScriptSlider.setPosition(int x, int y, int w, int h)



setPropertiesFromJSON

Restores all properties from a JSON object.

ScriptSlider.setPropertiesFromJSON( var jsonData)



setRange

Sets the range and the step size of the knob.

ScriptSlider.setRange(double min, double max, double stepSize)



setStyle

Sets the style Knob, Horizontal, Vertical.

ScriptSlider.setStyle(String style)



setTooltip

Shows a informative text on mouse hover.

ScriptSlider.setTooltip( String tooltip)



setValue

Sets the current value

ScriptSlider.setValue(var newValue)



setValueNormalized

Set the value from a 0.0 to 1.0 range

ScriptSlider.setValueNormalized(double normalizedValue) override



setValuePopupFunction

Pass a function that takes a double and returns a String in order to override the popup display text.

ScriptSlider.setValuePopupFunction(var newFunction)



setValueWithUndo

Sets the current value and adds it to the undo list. Don't call this from onControl!

ScriptSlider.setValueWithUndo(var newValue)



setZLevel

Changes the depth hierarchy (z-axis) of sibling components (Back, Default, Front or AlwaysOnTop).

ScriptSlider.setZLevel(String zLevel)



showControl

Hides / Shows the control.

ScriptSlider.showControl(bool shouldBeVisible)



updateContentPropertyInternal

This updates the internal content data object from the script processor.

ScriptSlider.updateContentPropertyInternal(int propertyId,  var newValue)



updateValueFromProcessorConnection

Updates the value from the processor connection. Call this method whenever the module state has changed and you want to refresh the knob value to show the current state.

ScriptSlider.updateValueFromProcessorConnection()