beta
cables is under heavy development.
There might be one or another bug, please let us know about it!
cables Documentation      How To Use            Working with files            Keyboard Shortcuts            User Interface Walkthrough      Beginner Tutorial            Beginner 1: Drawing A Circle            Beginner 2: Transformations            Beginner 3: Color            More Transformations      intermediate            Image Compositions            Post-Processing 3D Scenes      communication            cables API            Communication with an Arduino via Serial            Communicating with Arduino over MQTT      Exporting And Embedding            How to serve files externally and fix CORS headers            Embedding Patches            External triggers / functions            Embedding Patches            Previewing / uploading exported cables patches      coding ops            Creating Attachments            General op/Port Callbacks            Ports                  Dynamic Ports                  Array Ports                  Boolean ports                  Integer Number Ports                  Object Ports                  String ports                  Trigger Ports                  Floating Point Number Ports            GUI/UI attributes            Hello Op - Part 1            Libraries            Developing Ops            Guidelines            Object Ports            Writing Shaders            Web Audio Op Development      HTML and CSS in cables      Lighting            Lights            Shadows      FAQ            Embedding                  How to remove grey rectangles on touch (mobile)?                  Why doesn't the DownloadTexture op work on iOS?                  How to disable page scrolling on mobile?                  Transparent Canvas            Features and Support                  Will there be support for (animated) GIFs?            General questions            Licences and payment                  What licence do i need to use cables?                  Will I have to pay for it in the future?                  How is my work licenced when using cables?            Does cables support midi and OSC?            Shadertoy            Technical questions            UI / Editor            WebGL1 and WebGL2

GUI/UI attributes

Group Ports

to bundle ports into groups and set a visual divider between them:

op.setPortGroup('Display',[portScale,portFont]);
op.setPortGroup('Alignment',[portAlign,portVAlign]);
op.setPortGroup('Color',[r,g,b,a]);

Hide port

To hide a port on a op but still have a UI element use the following code

portName.hidePort();

Warnings and Errors

Ui attributes of an op can be set to give the user warnings and give visual feedback about things that may require their attention.


The following example will give an error in the OP UI and show a red circle if the value coming in is above 1.0


Button

If the value is lower than 0 then the UI will show this message
Button

//create a port for value input
const inVal  = op.inValueFloat ("Value in");
//create a port for value output
const outVal = op.outValue("value out");

//when inVal changes run this function
inVal.onChange = function()
{

    if(inVal.get() > 1.0)
    {
        //this causes the op to show a red circle
        //and show "There's an error" in the op UI
        op.uiAttr({ error :"There's an error"});
    }
    else
    {
        //clear the UI 
        op.uiAttr({ error : null });
    }
    if(inVal.get() < 0.0)
    {
        //if value in is below 0.0 the following message is displayed 
        //in the UI
        op.uiAttr({ warning :"There's a problem, value is below 0.0"});
    }
    else
    {
        //clear the UI 
        op.uiAttr({ warning : null });
    }
};

help cables get better and edit this file on github