Skip to content

Make a custom mouse area ​

Needs MNodes 1.1.5 or newer

Scene and all of its nodes are new in MNodes 1.1.5. They do not exist in older versions, so a project that uses them will not work there until you update.

A zone is the area where Scene listens to your mouse. Its drawing is separate.

Start with Scene Zone to create and test an area without writing code. The optional shader example below makes a disc brighter when you drag up and darker when you drag down.

The disc you will make

For a ready-made slider or knob with its own drawing and mouse behaviour, use Scene controls. Use Scene Zone when you want to choose the mouse area yourself.

Start without code: Scene Zone ​

  1. Add Scene Zone, Scene Circle and Scene.
  2. Connect Scene Zone — Zones → Scene — Zones (blue pins).
  3. Connect Scene Circle — Object → Scene — Objects (violet pins).
  4. On Circle, set X 50, Y 50 and Radius 15 with Percent units.
  5. Leave Zone at Knob, Circle, X 35, Y 35, Width 30, Height 30.
  6. Keep Show Zones on. The outline shows exactly where you can drag.
  7. Drag up and down inside the area. Touch, the new output on Scene, changes between 0 and 1.

Scene Zone connected to a Scene, with a circle underneath the mouse area

The zone handles the mouse. The Circle draws the picture. You can replace the Circle with your own drawing later.

Which cable does what? ​

FromToWhat it does
Scene Zone Zones outputScene Zones inputDefines the mouse area; blue Data cable
Scene Circle Object outputScene Objects inputDraws the circle; violet Object cable
Scene Touch outputA numeric input you want to controlSends the value as you drag; blue Data cable

The value comes out of Scene, not Scene Zone. Name sets that output's label: the default is Touch. The Circle will stay the same until you connect the value to something that changes its drawing. Creating a zone alone does not change sound either.

Set the area and its behaviour ​

Setting on Scene ZoneWhat to choose
TypeKnob for an up/down drag, Button while held, Toggle for on/off, or Slider / XY Pad for a pointer position
ShapeRectangle, Circle or Ring: where the mouse is accepted
X / YThe lower-left corner, in percent of Scene
Width / HeightThe area's size, in percent of Scene
Minimum / MaximumThe values sent to the patch; for example 0 and 1
DefaultThe initial value, also restored by double-clicking the zone
Show ZonesShow the outline and name while you work

More options are in Inspector → Zone, including Sensitivity, Step, the slider's Vertical direction and Tooltip. A Step of 0 allows smooth movement. Hold Shift while playing a knob zone for smaller changes.

See and test your area ​

  1. Leave Show Zones on in Scene Zone.
  2. Change X, Y, Width or Height on that node. Watch the outline move in Scene.
  3. Leave Scene's Edit Zones off while testing the gesture. It is an editing mode, not a playing mode.
  4. Drag inside the outline and watch Touch on Scene. For a Knob zone, the drag continues outside the outline until you release.

With a Scene Zone node connected, keep editing the area on that node: it supplies the zone definition. The drawing and the outline have separate positions, so move or resize the Circle too if you want them to match.

Add more areas ​

To add another area, connect the first Zone's Zones output to the second Zone's Zones input. Connect the last Zone to Scene. Give each a different Name and Zone ID. Keep those IDs unchanged once you connect outputs or record automation.

For example: Scene Zone “Cutoff” → Scene Zone “Resonance” → Scene Zones. Use IDs 1 and 2. Scene then provides outputs called Cutoff and Resonance. The first two cables carry zone definitions; take the playable values from Scene's outputs.

The outlines show only while you design: Perform and a locked Front Panel hide them. Bypassing a Zone removes that area and keeps the earlier areas in the chain.

X and Y are percentages from the lower-left corner. Native shapes use the upper-left corner. The example above centres both, so their positions match. A zone stays invisible when its guide is hidden; it does not create a knob drawing by itself.

You can stop here: no Shader Code or JSON is needed for this route. To record the zone in your DAW, follow the automation steps. For a complete built-in example, open Help from the Scene Zone node's menu.

Alternative: define a zone in text ​

The remaining steps show the same system using the Inspector and Shader Code. Use this route when you want a custom shader drawing. You can also supply its zone with Scene Zone: set Name to Amount, Maximum to 100, Default to 35, Y to 25, and Height to 50.

1. Add the drawing nodes ​

In an empty project, add Scene and Shader Code.

Connect Shader Code — Code → Scene — Code. This sends the drawing instructions to Scene.

Shader Code output
Code output
Scene input
Code input on Scene

Use Shader Code, not Script, for this example. Keep Scene Ignore Clicks off.

2. Open the zone settings ​

Select Scene. Open Inspector with Ctrl+I / Cmd+I. Search for Zones. Expand Canvas if its settings are hidden.

Where to find Zones in the Scene Inspector

Replace the Zones field with this complete text, including the square brackets:

json
[
  {
    "id": 1,
    "name": "Amount",
    "type": "knob",
    "shape": "circle",
    "x": 0.35, "y": 0.25,
    "w": 0.30, "h": 0.50,
    "min": 0, "max": 100,
    "default": 35,
    "unit": " %"
  }
]

You should see: an Amount output on Scene. The picture is still empty: the zone defines where to drag, but does not draw the disc.

What do these settings mean?
SettingMeaning
nameThe control is called Amount.
type: knobDrag up/down to change it. It does not have to look like a knob.
shape: circleThe mouse area is circular.
x / yWhere its lower-left corner sits. 0.35 means 35% across; 0.25 means 25% up.
w / hIts width and height as shares of Scene.
min / maxThe output goes from 0 to 100.
defaultIt starts at 35.
idA stable identifier. Keep it when editing this control.

Zones measure from the bottom left in 0–1. Native Scene objects use top-left positions, with Pixels or Percent units. Their numbers are not interchangeable.

3. Add the drawing ​

Open the connected Shader Code editor. Replace its code with this and apply:

glsl
void mainImage(out vec4 colour, in vec2 p) {
    vec2 centre = zoneCenter(Amount);
    float radius = min(zoneSize(Amount).x, zoneSize(Amount).y) * 0.42;
    float disc = 1.0 - smoothstep(-1.0, 1.0, length(p - centre) - radius);
    vec3 tint = mix(vec3(0.08, 0.15, 0.19),
                    vec3(0.35, 0.85, 0.95), zoneValue(Amount));
    colour = vec4(mix(vec3(0.025), tint, disc), 1.0);
}

You should see: a blue disc. Its drawing reads the Amount zone you just created.

Shader Code connects to Scene Code; Amount is now an output

Open the working disc project

4. Show where you can click ​

Right-click the Scene title. Turn on Show Zones.

You should see: an outline around the mouse area.

The real Show Zones overlay

Edit Zones lets you move and resize that area. Turn Edit Zones off before playing it. Show Zones can also be turned off to hide the outline.

5. Drag the disc ​

Press inside the disc and keep the mouse held. Drag up, then down.

You should see: it gets brighter, then darker. You can keep dragging outside the disc until you release. Hold Shift for smaller changes.

The brighter disc after dragging up

The Amount pin sends 0–100. The drawing's zoneValue(Amount) reads the same position as 0–1. For example, output 72 becomes 0.72 in the brightness mix.

6. Let a slider change it too ​

On Scene, enable Zone Inputs in Inspector.

Zone Inputs in the Scene Inspector

You should see: an Amount input on the left, as well as the output on the right.

Add Scene Slider and set Min 0, Max 100, Value 35. For this layout, set X 10, Y 82, Width 80, Height 5, with Units = Percent.

Connect:

  1. Slider Object → Scene Objects to show the slider.
  2. Slider Out → Scene Amount input to change the disc.

Both cables from the slider to Scene

Move the slider to 72.

You should see: the disc becomes brighter.

The disc after receiving 72 from the slider

Open the slider-and-disc project

This cable works from slider to disc. Dragging the disc does not move the slider back. Two-way control updates are the next step.

If it does not work ​

ProblemFix
Code error mentioning AmountUse the exact zone name Amount, including the capital A.
Empty pictureCheck the Code cable and the code editor's error message.
Disc moves instead of brighteningTurn Edit Zones off.
Mouse does nothingKeep Ignore Clicks and Bypass off. Show Zones to check the click area.
Slider barely changes the discUse Out with a 0–100 range, not Position.

To automate this zone, enable Expose to DAW on Scene. Follow the automation steps.

MNodes Documentation