Button (Information button)

Infobuttons can be used to open html files in the system's default web browser. When clicked, the file passed to the file() identifier will be opened. The file can be a local file, or a full URL such as file("http://cabbageaudio.com").

This widget can be useful for providing help files, or any other additional information about your instruments.

infobutton file("filename"), active(val), alpha(val), bounds(x, y, width, height), colour:0("colour"), colour:1("colour"), corners(val), fontColour:0("colour"), fontColour:1("colour"), identChannel("channel"), channel("chan"), parent(val), popup(val), imgFile("type", "file"), text("string"), visible(val), toFront(), moveBehind("widgetName"), widgetArray("chan", number),

Specific Identifiers


file("filename") This identifier is used across a number of widgets.

combobox and listbox - will load lines from a file as selectable items.
gentable and soundfiler - will load a sound file to display
image - will load an iamge to display (PNG/JPG/SVG)
infobutton - sets the file to display when the button is clicked This can be a local html file, or a URL.
texteditor - sets the file to load, should be a text file.

If a full file path is not given, file() will search in the current directory, i.e., the directory that contains the csd file that is open. It is best to keep all files in the same directory as your csd file. If you wish to keep them in a separate folder use relative paths, i.e, ../../folder.

Avoid absolute path at all costs. Failure to do so will most likely problems with your instruments as soon as you share them.

Common Identifiers


active(val) Will deactivate a control if 0 is passed. Controls which are deactivate can still be updated from Csound.


alpha(val) A value between 0 and 1 will set the alpha blend value for the entire component. Can be useful if you need to fade widgets in and out.


bounds(x, y, width, height) integer values that set position and size on screen(in pixels).


colour:0("colour") This sets the colour of the button when it's value is 0. Any CSS or HTML colour string can be passed to this identifier. The colour identifier can also be passed an RBG, or RGBA value. All channel values must be between 0 and 255. For instance colour(0, 0, 255) will create a blue, while colour(0, 255, 0, 255) will create a green with an alpha channel set to full.


colour:1("colour") This sets the colour of the button when it's value is 1. See above for details on valid colours.

You can create an invisible button by setting the colour to something with an alpha value of 0. Images can then be placed under the button to create an image button.


corners(val) Sets the radius size of the widget's corners.


fontColour:0("colour")Sets the colour of the text that appears on the button when it's in its off state. See above for details on valid colours.


fontColour:1("colour") Sets the colour of the text that appears on the button when it's in its on state. See above for details on valid colours.


identChannel("channel") [!!! DEPRECATED !!!] Although identifier channels still work, they are no longer supported. Please use the new guiMode("queue") system and the cabbageGet and cabbageSet opcodes instead. They are far more efficient then identifiers channel.


channel("chan") or channel("chan1", "chan2") in the case of widgets that accept two channels such as xypad, soundfiler and range widgets. channel() accepts a string/s that names the channel/s that Cabbage will communicate with Csound on. The current value of this widget can be retrieved in Csound using a chnget, or a cabbageGetValue opcode. Its value can be set using the cabbageSet, or cabbageSetValue opcodes. hrange, vrange, xypad, and soundfiler all take two channels:

hrange, vrange : channel("min", "max") - min and max values

xypad : channel("x", "y") - x and y values

soundfiler : channel("start", "length") - start time and length of user selection, in samples

Channels named should start with a letter and cannot have any white spaces. Note that all widgets should have a unique channel name.


parent(val) This identifier is can be to set a widget's parent. It should only be used when creating widgets dynamically using the cabbageCreate opcode. See plants for more details.


popup(val) This identifier, used with an image or groupbox will convert the plant into a popup plant. The plant will not be shown on the instrument's main interface, but will instead appear when the user sets visible to 1. < DAWs treat popup dialogue windows in different ways. As a result, you may notice inconsistent behaviour when running your instruments as plugins across a variety of different hosts.


imgFile("type", "file") Use this identifier to set a unique .svg or .png file to be used instead of the default look and feel. "type" should be one of the following:

Buttons:
- "on" : sets the button image when it is on - "off" : sets the button image when it is off
Sliders:
- "background" : sets the slider background image - "slider" : sets the slider thumb, or in the case of a rotary slider, the inner circle. This image moves in sympathy with that the mouse as users move the slider.

For more information see Using SVGs and PNGs


text("string") "string" will be the text that appears on the widget. button widgets take two strings, one for on and one for off.


visible(val) A value of 0 will cause the widget to become invisible. Widgets have their visibility set to 1 by default.


toFront() Brings a widget to the front of the z order. This identifier takes no arguments and is only intended for use within the Csound orchestra. it makes no sense to call it when declaring the widget.


moveBehind("widgetName") Moves a widget directly behind another. This identifier should only ever be called from your Csound orchestra using a cabbageSet opcode.

This only works with widgets or plants that have the same parent.


widgetArray("chan", number) [!!! DEPRECATED !!!] Deprecated. Please see the section on Managing large numbers of widgets

Example

<Cabbage>
form caption("Info Button Example") size(380, 300), guiMode("queue"), , colour(2, 145, 209) pluginId("def1")

infobutton bounds(16, 12, 340, 36) file("https://cabbageaudio.com/docs/introduction/") text("Load Cababge Documentation"), corners(5)

texteditor bounds(16, 68, 341, 72) channel("infoText"), readOnly(1), wrap(1), scrollbars(1)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d 
</CsOptions>e
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

; Rory Walsh 2021 
;
; License: CC0 1.0 Universal
; You can copy, modify, and distribute this file, 
; even for commercial purposes, all without asking permission. 

instr 1
    SText  = "An infobutton can be used to load a html file, or a hyperlink. It doesn't receive any information from Csound, but you can still update its appearance and position by sending identifier data to its channel"
    cabbageSet "infoText", "text", SText
endin


</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 z
</CsScore>
</CsoundSynthesizer>