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

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
pthirkell
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 93
Joined: Tue Nov 17, 2009 6:47 pm
Location: Wellington, New Zealand

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

Post by pthirkell » Fri May 06, 2016 10:36 pm

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 :?:

livecodeali
Livecode Staff Member
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

Post by livecodeali » Sun May 08, 2016 10:26 pm

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"

pthirkell
VIP Livecode Opensource Backer
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

Post by pthirkell » Mon May 09, 2016 1:11 am

Ah ... so easy and elegant :D Many thanks prompt clarification!

Post Reply

Return to “LiveCode Builder”