TwDefine (function)

int TwDefine(const char *def)

Description

This function defines optionnal commands for tweak bars and variables. For instance, it allows you to change the color of a tweak bar, to set a min and a max value for a variable, to add an help message that inform users of the meaning of a variable, and so on...

Parameter

def

A string containing one or more commands (separated by newlines).

To define bar parameters, the command syntax is:

barName  barCommand1 barCommand2 ...

where barName is the name of the tweak bar (the same as the one provided to TwNewBar), and barCommandn follows the bar commands syntax.

To define variable parameters, the command syntax is:

barName/varName  varCommand1 varCommand2 ...

where barName is the name of the tweak bar (the same as the one provided to TwNewBar), varName is the name of the variable (the same as the one provided to TwAddVar*), and varCommandn follows the variable commands syntax.

If barName or varName contains special characters like spaces or quotation marks, you can surround it by quotes (), back-quotes (`) or double-quotes ().

Examples

Return values

  • 0 if an error has occurred (call TwGetLastError to retrieve the error).
  • 1 otherwise.

Note

Using a text file to define commands

One or more commands can be defined by each TwDefine call. If you want to execute more than one command through one TwDefine call, separate them by new lines (\n). This allows, for instance, the read of define commands from a file into a string buffer, and then send this string to TwDefine. Doing so, you can modify the behavior of your tweak bars and variables without re-compiling your application.

See also


Log in to edit this page