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
defining min/max and step when using com.livecode.pi.number
-
- Livecode Staff Member
- Posts: 192
- Joined: Thu Apr 18, 2013 2:48 pm
Re: defining min/max and step when using com.livecode.pi.num
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"
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"
-
- VIP Livecode Opensource Backer
- Posts: 93
- Joined: Tue Nov 17, 2009 6:47 pm
- Location: Wellington, New Zealand
Re: defining min/max and step when using com.livecode.pi.num
Ah ... so easy and elegant Many thanks prompt clarification!