Built-in properties
Built-in properties
So I'm looking over the list of built-in properties that can be accessed, but I cannot find any documentation as to how to use them.
Is there a way to call textFont and/or textSize other than through "my font"? Say I just wanted to get the size, how would I get it?
Also I'm looking at these properties, how can I call these properties in a handler (and what Type of variable do I need)?
backPattern
backPixel
blendLevel
customKeys
customProperties, customPropertySet, customPropertySets,
ink
invisible, visible
kind
layer, layerMode
number
parentScript
patterns
penColor
properties
script
selected
textStyle
themeControlType
toolTip
Is there a way to call textFont and/or textSize other than through "my font"? Say I just wanted to get the size, how would I get it?
Also I'm looking at these properties, how can I call these properties in a handler (and what Type of variable do I need)?
backPattern
backPixel
blendLevel
customKeys
customProperties, customPropertySet, customPropertySets,
ink
invisible, visible
kind
layer, layerMode
number
parentScript
patterns
penColor
properties
script
selected
textStyle
themeControlType
toolTip
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Built-in properties
I'm not entirely sure what you mean by this.how can I call these properties in a handler (and what Type of variable do I need)?
Do you mean this sort of thing:
set the backPattern of graphic "SPLODGE' to the ID of img "PIGGY" ?
Because, if you do, there is no single, simple answer as many of the properties of an object are dealt with in many different ways.
In the in-built Dictionary all of these properties are explained: it just involves some time and effort to work one's way through them.
Although for 'backPixel' and backPattern you must be careful to use their BIG names: backgroundPixel and backgroundPattern.
-
Last edited by richmond62 on Tue Aug 21, 2018 8:47 am, edited 1 time in total.
Re: Built-in properties
what I am interested in is how to apply these properties within LCB, how do I call them in a handler
I mean some of them I might not have a need for within tht ewidget's code, but what does setting a pattern do? does setting the backPattern just do something, or do i have to tell the widget to do something with it (and thus how)?
if these are properties we can incorporate into a widget, how do we utilize them in Livecode Builder? And if they can't be used within Livecode Builder, then what happens to the widget when they are set?
I grabbed this list (partial) from one of the widget courses, I took out the ones I already knew how to access (like background paint and font).
I mean some of them I might not have a need for within tht ewidget's code, but what does setting a pattern do? does setting the backPattern just do something, or do i have to tell the widget to do something with it (and thus how)?
if these are properties we can incorporate into a widget, how do we utilize them in Livecode Builder? And if they can't be used within Livecode Builder, then what happens to the widget when they are set?
I grabbed this list (partial) from one of the widget courses, I took out the ones I already knew how to access (like background paint and font).
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Re: Built-in properties
For each of these properties search their name in the dictionary and you will see you can do things like:
Code: Select all
set the size of my font to 20
Code: Select all
set the red of the color of my background paint to 1
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Built-in properties
"New York, New York; so good they named it twice."For each of these properties search their name in the dictionary and you will see you can do things like:
Re: Built-in properties
Let me try this from another direction.
I've been playing with textAlign and textStyle.
If I enable the textStyle property and set the bold and/or italic, it appears that "my font" becomes bold or italicized. None of the other textStyle properties seem to do anything.
If I enable textAlign, it does not seem to have any natural effect when it is set. SO either it doesn't do anything, or I need to do something to make it work.
So how do I utilize the textAlign property?
Here's the widget I am playing with:
I've been playing with textAlign and textStyle.
If I enable the textStyle property and set the bold and/or italic, it appears that "my font" becomes bold or italicized. None of the other textStyle properties seem to do anything.
If I enable textAlign, it does not seem to have any natural effect when it is set. SO either it doesn't do anything, or I need to do something to make it work.
So how do I utilize the textAlign property?
Here's the widget I am playing with:
Code: Select all
widget pink.mad.practice
metadata title is "MPPractice"
metadata author is "MadPink"
metadata version is "0.0.0"
metadata preferredSize is "200,80"
use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
property someText get mText set setText
metadata someText.editor is "com.livecode.pi.text"
metadata someText.default is "So it goes."
metadata someText.section is "Advanced"
private variable mText as String
metadata foregroundColor.editor is "com.livecode.pi.color"
metadata foregroundColor.default is "255,255,255"
metadata foregroundColor.section is "Colors"
metadata foregroundColor.label is "Text Color"
metadata backgroundColor.editor is "com.livecode.pi.color"
metadata backgroundColor.default is "255,15,192"
metadata backgroundColor.section is "Colors"
metadata backgroundColor.label is "Button Color"
metadata textFont.editor is "com.livecode.pi.font"
metadata textSize.editor is "com.livecode.pi.integer"
metadata textSize.default is "18"
metadata textStyle.editor is "com.livecode.pi.textstyle"
metadata textAlign.editor is "com.livecode.pi.textalign"
public handler OnSave(out rProperties as Array)
put the empty array into rProperties
put mText into rProperties["someText"]
end handler
public handler OnLoad(in pProperties as Array)
put pProperties["someText"] into mText
end handler
private handler setText(in pText as String)
put pText into mText
end handler
public handler OnCreate()
end handler
public handler OnPaint()
variable tRect as Rectangle
set the paint of this canvas to my background paint
fill rounded rectangle path of rectangle [0,0,my width, my height] with radius 42 on this canvas
set the font of this canvas to my font
set the paint of this canvas to my foreground paint
fill text mText at point [my width/3,my height/2] on this canvas
--put rectangle [20,20,my width-20, my height-20] into tRect
--fill text mText at top left of tRect on this canvas
end handler
end widget
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Built-in properties
Property textAlign is in LCS a property of a field or button.
There are no fields or buttons in LCB (except, as a widget, a Mac-native one-line-field).
So you have to measure the textbox (image bounds of text tText). Then you can align the <whatever> of the textbox exactly to the <whatever> of the canvas using "fill text".
There are no fields or buttons in LCB (except, as a widget, a Mac-native one-line-field).
So you have to measure the textbox (image bounds of text tText). Then you can align the <whatever> of the textbox exactly to the <whatever> of the canvas using "fill text".
shiftLock happens
Re: Built-in properties
I seem to be going in circles, here's the point I'm making. We have a list of built-in properties that we can activate in a widget. I'm using textAlign as an example. As I see it, there are 4 possiblities:
1. Setting a built-in property in a widget just works, and can be utilized with statements like "my font" and "my background"
2. Setting a built-in property does nothing out of the box, and needs to be called in a handler (similar to how props that we create work)
3. Setting a built-in property works by itself, but cannot be accessed or manipulated within the widget (I believe that "toolTip" works this way)
4. Setting a built-in property does nothing at all.
It seems to me that textAlign falls into the last category, in which case it would be helpful to know that. Maybe the answer is "nothing... yet." That would be fine too.
Which brings me back to the list of built-in properties.
If a built-in property doesn't do anything, it would be helpful to know that.
If I take a property like "selected" or "textAlign" or "customKeys" and add them to the properties of my widget, I want to know what they do for my widget. I don't care what each does in other things, I'm talking about building a widget with that property. It is either useable or it is useless.
1. Setting a built-in property in a widget just works, and can be utilized with statements like "my font" and "my background"
2. Setting a built-in property does nothing out of the box, and needs to be called in a handler (similar to how props that we create work)
3. Setting a built-in property works by itself, but cannot be accessed or manipulated within the widget (I believe that "toolTip" works this way)
4. Setting a built-in property does nothing at all.
It seems to me that textAlign falls into the last category, in which case it would be helpful to know that. Maybe the answer is "nothing... yet." That would be fine too.
Which brings me back to the list of built-in properties.
If a built-in property doesn't do anything, it would be helpful to know that.
If I take a property like "selected" or "textAlign" or "customKeys" and add them to the properties of my widget, I want to know what they do for my widget. I don't care what each does in other things, I'm talking about building a widget with that property. It is either useable or it is useless.
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Re: Built-in properties
You need to read the value of the property and then adjust your code accordingly. Those properties are just values, it is up to your code to give them meaning as appropriate for your widget.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Built-in properties
this brings me back to my original question... how?
how do I use the textAlign property in my code?
how do I use the selected property in my code?
how do I use the penColor property in my code?
how do I access them in my code?
how do I use the textAlign property in my code?
how do I use the selected property in my code?
how do I use the penColor property in my code?
how do I access them in my code?
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Re: Built-in properties
Code: Select all
property textAlign get mTextAlign set mTextAlign
metadata textAlign.editor is "com.livecode.pi.textalign"
private variable mTextAlign as String
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Built-in properties
From the widgets course:
Some built-in properties just seem to work, some don't
If the way to use them is to define them, then A. the statement above from the widgets course is wrong, and B. I don't see the point in using a "built-in" property instead of one defined on my own.You can also link to other standard Livecode properties beyond the basic, built in set.
(misc example info)
To access it we have to specify that the widget has the property, but we do not have to define the property itself.
Some built-in properties just seem to work, some don't
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Re: Built-in properties
The advantage is that you don't have to manually load/save the values. Look at the "my" entries in the LCB dictionary. Not all of the properties that you listed are covered.
Color is probably the easiest example. Standard color settings are available within the widget (my background paint, my border paint...). These can be set in the PI and are automatically saved with the widget in the stack.
I've looked through the widgets in the repository and don't see examples of other properties.
I've looked at the source, and the font is a pointer to the current effective font of the widget to include the textFont, textSize, and textStyle properties. There does not appear to be a way to individually address any of those properties from inside the widget. You could use "execute script" I suppose to read/change the values.
As to how to access things like the custom properties and other settings not covered in the dictionary, I'm not sure. I can see in the widget.lcb file that only the stuff in the dictionary is covered there (which makes sense because the dictionary is generated from the lcb files).
Color is probably the easiest example. Standard color settings are available within the widget (my background paint, my border paint...). These can be set in the PI and are automatically saved with the widget in the stack.
I've looked through the widgets in the repository and don't see examples of other properties.
I've looked at the source, and the font is a pointer to the current effective font of the widget to include the textFont, textSize, and textStyle properties. There does not appear to be a way to individually address any of those properties from inside the widget. You could use "execute script" I suppose to read/change the values.
As to how to access things like the custom properties and other settings not covered in the dictionary, I'm not sure. I can see in the widget.lcb file that only the stuff in the dictionary is covered there (which makes sense because the dictionary is generated from the lcb files).
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- VIP Livecode Opensource Backer
- Posts: 4027
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Built-in properties
If you doI've looked at the source, and the font is a pointer to the current effective font of the widget to include the textFont, textSize, and textStyle properties. There does not appear to be a way to individually address any of those properties from inside the widget. You could use "execute script" I suppose to read/change the values.
Code: Select all
private variable mFont as Font -- defined outside of a handler
-- inside a handler
put my font into mFont
log the size of mFont
log the name of mFont
this did not work for "style" nor "textstyle"
trying to log "size" or "name" from "my font" fails as compilation error.
you can then set name and/or size of mFont and use mFont
Kind regards
Bernd