HISE Docs

ScriptSlider


Create a reference to a Slider UI component and modify its values.

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


Class methods

addToMacroControl

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

ScriptSlider.addToMacroControl(int macroIndex)



changed

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

ScriptSlider.changed()



contains

Checks if the given value is within the range. Edit on GitHub

ScriptSlider.contains(double value)



createLocalLookAndFeel

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

ScriptSlider.createLocalLookAndFeel(ScriptContentComponent *contentComponent, Component *componentToRegister)



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. Edit on GitHub

ScriptSlider.fadeComponent(bool shouldBeVisible, int milliseconds)



get

returns the value of the property. Edit on GitHub

ScriptSlider.get(String propertyName)



getAllProperties

Returns a list of all property IDs as array. Edit on GitHub

ScriptSlider.getAllProperties()



getChildComponents

Returns list of component's children Edit on GitHub

ScriptSlider.getChildComponents()



getGlobalPositionX

Returns the absolute x-position relative to the interface. Edit on GitHub

ScriptSlider.getGlobalPositionX()



getGlobalPositionY

Returns the absolute y-position relative to the interface. Edit on GitHub

ScriptSlider.getGlobalPositionY()



getHeight

Returns the height of the component. Edit on GitHub

ScriptSlider.getHeight()



getId

Returns the ID of the component. Edit on GitHub

ScriptSlider.getId()



getLocalBounds

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

ScriptSlider.getLocalBounds(float reduceAmount)



getMaxValue

Returns the upper range end. Edit on GitHub

ScriptSlider.getMaxValue()



getMinValue

Returns the lower range end. Edit on GitHub

ScriptSlider.getMinValue()



getValue

Returns the current value. Edit on GitHub

ScriptSlider.getValue()



getValueNormalized

Returns the normalized value. Edit on GitHub

ScriptSlider.getValueNormalized()  override



getWidth

Returns the width of the component. Edit on GitHub

ScriptSlider.getWidth()



grabFocus

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

ScriptSlider.grabFocus()



loseFocus

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

ScriptSlider.loseFocus()



sendRepaintMessage

Manually sends a repaint message for the component. Edit on GitHub

ScriptSlider.sendRepaintMessage()



set

Sets the property. Edit on GitHub

ScriptSlider.set(String propertyName, var value)



setColour

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

ScriptSlider.setColour(int colourId, int colourAs32bitHex)



setConsumedKeyPresses

Registers a selection of key presses to be consumed by this component. Edit on GitHub

ScriptSlider.setConsumedKeyPresses(var listOfKeys)



setControlCallback

Pass a inline function for a custom callback event. Edit on GitHub

ScriptSlider.setControlCallback(var controlFunction)



setKeyPressCallback

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

ScriptSlider.setKeyPressCallback(var keyboardFunction)



setLocalLookAndFeel

Attaches the local look and feel to this component. Edit on GitHub

ScriptSlider.setLocalLookAndFeel(var lafObject)



setMaxValue

Sets the upper range end to the given value. Edit on GitHub

ScriptSlider.setMaxValue(double max)



setMidPoint

Sets the value that is shown in the middle position. Edit on GitHub

ScriptSlider.setMidPoint(double valueForMidPoint)



setMinValue

Sets the lower range end to the given value. Edit on GitHub

ScriptSlider.setMinValue(double min)



setMode

Sets the knob to the specified mode. Edit on GitHub

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. Edit on GitHub

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



setPropertiesFromJSON

Restores all properties from a JSON object. Edit on GitHub

ScriptSlider.setPropertiesFromJSON( var jsonData)



setRange

Sets the range and the step size of the knob. Edit on GitHub

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



setStyle

Sets the style Knob, Horizontal, Vertical. Edit on GitHub

ScriptSlider.setStyle(String style)



setStyleSheetClass

Sets the given class selectors for the component stylesheet. Edit on GitHub

ScriptSlider.setStyleSheetClass( String classIds)



setStyleSheetProperty

Sets a variable for this component that can be queried from a style sheet. Edit on GitHub

ScriptSlider.setStyleSheetProperty( String variableId,  var value,  String type)



setStyleSheetPseudoState

Programatically sets a pseudo state (:hover, :active, :checked, :focus, :disabled) that will be used by the CSS renderer. Edit on GitHub

ScriptSlider.setStyleSheetPseudoState( String pseudoState)



setTooltip

Shows a informative text on mouse hover. Edit on GitHub

ScriptSlider.setTooltip( String tooltip)



setValue

Sets the current value Edit on GitHub

ScriptSlider.setValue(var newValue)



setValueNormalized

Set the value from a 0.0 to 1.0 range Edit on GitHub

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. Edit on GitHub

ScriptSlider.setValuePopupFunction(var newFunction)



setValueWithUndo

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

ScriptSlider.setValueWithUndo(var newValue)



setZLevel

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

ScriptSlider.setZLevel(String zLevel)



showControl

Hides / Shows the control. Edit on GitHub

ScriptSlider.showControl(bool shouldBeVisible)



updateContentPropertyInternal

This updates the internal content data object from the script processor. Edit on GitHub

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. Edit on GitHub

ScriptSlider.updateValueFromProcessorConnection()