com.livecode.pi

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
MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

com.livecode.pi

Post by MaxV » Wed Nov 16, 2016 1:13 pm

Hi,
where may I find information about "com.livecode.pi" ?
The dictionary hasn't that entry and I don't know how to deal with it.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: com.livecode.pi

Post by peter-b » Wed Nov 16, 2016 2:58 pm

"com.livecode.pi" refers to the IDE Property Inspector. We use the same naming scheme for several components, not limited to things written in LiveCode Builder.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.pi

Post by [-hh] » Wed Nov 16, 2016 5:23 pm

https://github.com/livecode/livecode-id ... tyInfo.txt

There are, connected to that, also examples of usage
= in several LC 8 release notes
= in example widgets (search for metadata *.editor is "com.livecode.pi.")

And there is somewhere (in this subforum?) a post by LC-Ali about using an PI editor.
shiftLock happens

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: com.livecode.pi

Post by MaxV » Thu Nov 17, 2016 9:42 am

The total lack of documentation for widgets leave me groping in the dark. :?:
So if I create a create a widget, that has a property called coolProp, I should use this code:

Code: Select all

property coolProp get coolProp set coolProp
Why do I have to repeat get and set after declaring it? What other options do I have?
If I want to permit to use the property inspector to set the coolProp, I have to use com.livecode.pi. Am I right?
If I want to leave the user to choose from a list, I use this code:

Code: Select all

metadata coolProp.editor is "com.livecode.pi.enum"
metadata coolProp.options is "first option, second option, third option,.."
So option name can't have a comma in their names, because options are comma separated. Is it right?
If I want to use a simple field to set properties, what code should I use?
If I want to use a check box to set properties, what code should I use?
If I want to use a scroller to set properties, what code should I use?
What other options do I have?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.pi

Post by [-hh] » Thu Nov 17, 2016 12:53 pm

Here some short answers.

Generally:

Code: Select all

property coolProp get <getter> set <setter>
  • If you don't use set <setter> then the property is read only.
  • The simplest form of "getter" or "setter" are variable names.
  • A typical setter is a handler as follows.

    Code: Select all

    private handler setCoolProp(in pValue as optional any)
      set mCoolVariable to pValue
      redraw all
    end handler
    This updates (if no timer is involved) the widget from the PI.
MaxV wrote:metadata coolProp.editor is "com.livecode.pi.enum"
metadata coolProp.options is "first option, second option, third option,.."
This defines an option menu for property coolProp. Options are separated by comma, the typed spaces are used (you indent options 2 and 3 above).
MaxV wrote:So option name can't have a comma in their names, because options are comma separated. Is it right?
Yes, of course, as always. This is not special to LC Builder!
MaxV wrote:If I want to use a simple field to set properties, what code should I use?
One-line field:

Code: Select all

metadata coolProp.editor is "com.livecode.pi.text"
Usual multiline text field:

Code: Select all

metadata coolProp.editor is "com.livecode.pi.string"
MaxV wrote:If I want to use a check box to set properties, what code should I use?
No special property editor (PI uses checkboxes for booleans) or

Code: Select all

metadata coolProp.editor is "com.livecode.pi.boolean"
MaxV wrote:If I want to use a scroller to set properties, what code should I use?
A full example:

Code: Select all

private variable mPercent

property "percent"  get mPercent  set setPercent
metadata percent.editor  is "com.livecode.pi.number"
metadata percent.min  is "0"
metadata percent.max  is "100"
metadata percent.step is "1"
metadata percent.default is "50"

private handler setPercent(in pPercent as Number) returns nothing
  put pPercent into mPercent
  redraw all
end handler
MaxV wrote:What other options do I have?
A special case are colors, you need a getter and a setter for conversion to/from strings. You'll find an example in my Basic Template ( LCB snippet #51).

Else read the release notes, read built-in examples or the community examples or, once again, use propertyInfo.txt.
shiftLock happens

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: com.livecode.pi

Post by MaxV » Thu Nov 17, 2016 2:10 pm

Stunding the propertyInfo.txt file seems that the option available are:
  • com.livecode.pi.boolean
  • com.livecode.pi.color
  • com.livecode.pi.colorwithalpha
  • com.livecode.pi.customprops
  • com.livecode.pi.decorations
  • com.livecode.pi.enum
  • com.livecode.pi.file
  • com.livecode.pi.font
  • com.livecode.pi.gradient
  • com.livecode.pi.gradientramp
  • com.livecode.pi.graphicEffect
  • com.livecode.pi.imageID
  • com.livecode.pi.image_id
  • com.livecode.pi.imageid
  • com.livecode.pi.integer
  • com.livecode.pi.nubmber
  • com.livecode.pi.number
  • com.livecode.pi.pattern
  • com.livecode.pi.point
  • com.livecode.pi.propertyProfile
  • com.livecode.pi.script
  • com.livecode.pi.stackfiles
  • com.livecode.pi.string
  • com.livecode.pi.styledText
  • com.livecode.pi.text
  • com.livecode.pi.textalign
  • com.livecode.pi.textstyle
Is it correct? Are they case sensitive?
com.livecode.pi.imageID
com.livecode.pi.image_id
com.livecode.pi.imageid
are the same?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.pi

Post by [-hh] » Thu Nov 17, 2016 2:41 pm

Yes, this is (besides your typos) available in the PI for LC as a whole.
Great work was done for the new PI! Perhaps we should always recall:

A widget is a control just like other controls in LiveCode.

All editors for properties that a control can have are available, not yet all implemented (for example 'gradient properties') for widgets. Of course you have to implement the properties that use those editors by your own. Reading github shows, they are working on better support for 'standard' properties (that other controls have) for widgets.
Code for using the editor 'file' can be found for example here:
http://forums.livecode.com/viewtopic.ph ... a8#p145027
MaxV wrote:Are they case sensitive?
com.livecode.pi.imageID
com.livecode.pi.image_id
com.livecode.pi.imageid
are the same?
Case sensitivity is the default in LCB, exceptions (for example with array keys) are denoted.
[And the different names for imageID are probably serving different stackfile versions].

LCB is still experimental, we all are testing and trying, why not you?
shiftLock happens

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: com.livecode.pi

Post by peter-b » Thu Nov 17, 2016 5:21 pm

[-hh] wrote:
MaxV wrote:Are they case sensitive?
com.livecode.pi.imageID
com.livecode.pi.image_id
com.livecode.pi.imageid
are the same?
Case sensitivity is the default in LCB, exceptions (for example with array keys) are denoted.
[And the different names for imageID are probably serving different stackfile versions].
Actually, LCB is case sensitive for string operations, but _not_ for identifiers (such as the name of a module, handler or variable). In this case, all of MaxV's examples would be considered identical.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: com.livecode.pi

Post by MaxV » Fri Nov 18, 2016 11:09 am

What is the difference between com.livecode.pi.imageID and com.livecode.pi.image_id?
Is just a mistyping on the file?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: com.livecode.pi

Post by peter-b » Fri Nov 18, 2016 11:27 am

MaxV wrote:What is the difference between com.livecode.pi.imageID and com.livecode.pi.image_id?
Is just a mistyping on the file?
The second one is a mis-typing. The first one is correct.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

Post Reply

Return to “LiveCode Builder”