Page 1 of 1

defining min/max and step when using com.livecode.pi.number

Posted: Fri May 06, 2016 10:36 pm
by pthirkell
The documentation says that, when defining a numerical property for a widget, we should use the com.livecode.pi.number editor in the LCB script of the widget being created. This editor is described as, "com.livecode.pi.number: a single-line field, with a slider if the property has an associated min/max and an increment/decrement twiddle if it has a step value." This is exactly what I would like to create in the properties inspector.

The LCB script for the "SVG Icon" widget contains this code for setting the "angle" property which appears with a slider and an increment/decrement twiddle in the properties inspector:

property "angle" get mAngle set setAngle
metadata angle.editor is "com.livecode.pi.number"
metadata angle.default is "0"
metadata angle.label is "Rotation"

... but I couldn't find any definition of min/max and the step value in the script.

How/where in Livecode Builder do we define the "associated" min/max, and also the desired "step value" ... when using the com.livecode.pi.number editor :?:

Re: defining min/max and step when using com.livecode.pi.num

Posted: Sun May 08, 2016 10:26 pm
by livecodeali
Because the 'angle' property is a built-in property (which is why the property in the lcb file is in double quotes), the property metadata for the widget's angle property is inherited from the metadata specified for built-in properties in this file:
https://github.com/livecode/livecode-id ... tyInfo.txt

If you want to define your own min, max and step for a widget property, just use the same pattern of property metadata, eg:

property myAngle ...
metadata myAngle.editor is "com.livecode.pi.number"
metadata myAngle.min is "0"
metadata myAngle.max is "359"
metadata myAngle.step is "1"

Re: defining min/max and step when using com.livecode.pi.num

Posted: Mon May 09, 2016 1:11 am
by pthirkell
Ah ... so easy and elegant :D Many thanks prompt clarification!