Knob Flags, Ranges, and Tooltips¶
Knob Flags¶
Knob flags provide a mean to customize aspects of a previously created knob. Flags can be added or removed from a knob using the SetFlags(callback, flags) and ClearFlags(callback, flags) calls singly or in combination using bitmask techniques. Knob flags should be used in the Knobs() creation call of your Op. Some have corresponding function calls on the knob object, which can be used in Op functions after the Knobs() call has completed - there is also a set_flag() call to achieve a similar result for those without such corresponding calls. In some circumstances, after such an update the knob interface may require manual refreshing through manual use of the appropriate updateWidgets(), redraw(), or changed() call. The most commonly used Flags are generic across all knobs and the remainder are specific to subsets of the full roster.
The flags are defined in Knob.h under the FlagMask enumeration.
For example, you could set a float knob to have a logarithmic slider and to be read only as below:
Float_knob(f, &_floatKnobData, "Float_knob");
SetFlags(Knob::LOG_SLIDER | Knob::READ_ONLY);
Where f is the knob callback, the _floatKnobData has been previously declared and initialized, and the Op code is using the DD::Image namespace.
Knob Ranges¶
Most numerical knobs in NUKE default to a range of 0 to 1, which is not necessarily what you’re after. SetRange can sort this out.
Knob Tooltips¶
Very importantly, and often overlooked, NUKE has the ability to assign tooltips to every knob you create. Do this, and do it as soon as you can, since ultimately there’ll always be somebody using your tool other than you, and like the rest of us they won’t read the manual first. Tooltips, coupled with the overall node help, are the perfect solution to this as they provide contextual help at the customers fingertips. In the long term, it’ll save you time in writing extensive per control manual entries and answering questions and support enquiries.
Adding a tooltip is dead easy - after your knob creation call add a Tooltip(<knob callback>, <text>) call. For the text you can use plain text coupled with ‘\n’ for newlines, basic tags such as <i> </i>, <b> </b>, and so on.