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

- Posts: 92
- Joined: Mon Jul 06, 2009 4:53 am
Post
by Peter Wood » Thu Apr 09, 2015 6:32 am
As well as the choice of colour, I found one "real" issues and a couple of other annoynances with the pink circle example.
The issue is the example uses "real" instead of "Real" which causes a compilation error.
The first annoyance is the radius of the circle is set to the width of the widget so it can display a "window" on a circle at times. I made the following change to the paint handler:
Code: Select all
public handler onPaint()
variable tCirclePath as Path
variable tShortest as Real
if my width < my height then
put my width into tShortest
else
put my height into tShortest
end if
put circle path centered at point [my width / 2, my height / 2] with radius ((tShortest - mMargin)/2) into tCirclePath
set the paint of this canvas to solid paint with color [0, 1, 0]
fill tCirclePath on this canvas
end handler
A another minor annoyance, some of the handlers start with "On" and some with "on".
It would be good if the docs could be updated in the next release.
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10053
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Thu Apr 09, 2015 6:42 am
I think I missed something: I remember when "private" was introduced - now we have to declare "public" for all non-private handlers?
-
Peter Wood
- VIP Livecode Opensource Backer

- Posts: 92
- Joined: Mon Jul 06, 2009 4:53 am
Post
by Peter Wood » Thu Apr 09, 2015 6:47 am
I can only answer by experimenting. It seems the public keyword is necessary. When I removed it from the onPaint handler, the code compiles but the widget doesn't display anything.
By the way, I am using the 8.0 DP 1 release.
-
peter-b
- Posts: 182
- Joined: Thu Nov 20, 2014 2:14 pm
Post
by peter-b » Thu Apr 09, 2015 10:06 pm
To confirm, the default visibility of handlers, variables, etc. is private. Only explicitly "public" definitions are exported from a module.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Fri Apr 15, 2016 12:09 pm
Thank you @PeterWood for the hint about "real" and "Real". I seem to have found another issue in the example as it appears in the "Extending LiveCode" bit of the Guide:
Code: Select all
public handler setMargin(in pMargin as real) as undefined
put pMargin into mMargin
redraw all
end handler
It's that final "as undefined" that is the problem - as far as I can tell this is a typo and it certainly won't compile for me when it's in place. In fact the only thing I can get to compile which has anything after the final bracket is "return as <type>". Is this correct or is there some other way of defining handlers I don't know about?
By the way, please note the "real" as opposed to "Real" in the above example from the Guide, I plan to attempt to send in pull requests on the Guide to tidy up these and other little niggles...
EDIT: forgot to say, "undefined" seems to be deprecated as a type anyway
Last edited by
dave.kilroy on Fri Apr 15, 2016 2:18 pm, edited 1 time in total.
"...this is not the code you are looking for..."
-
pink
- Posts: 280
- Joined: Wed Mar 12, 2014 6:18 pm
Post
by pink » Fri Apr 15, 2016 1:47 pm
is this example available publicly?
and what is wrong with pink?

Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Fri Apr 15, 2016 1:59 pm
Hi @pink!
Yes, in LC8 open the dictionary, choose the 'Guide' tab, then from the drop-down choose "Expanding LiveCode" - it's a really nice intro to LCB (at least it appeared so to me as a LCB newbie) - but it has several little typos and the example doesn't compile!
"...this is not the code you are looking for..."
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Fri Apr 15, 2016 6:09 pm
Hi all.
This example compiled here in one of the early dp-versions of LC8.
Meanwhile LCBuilder has changed some things, also lowercase and uppercase rules.
So the point is not a "wrong" example but a missing update to LCBuilder as of LC 8.0.0-rc-1.
Since you have it already running, please post the running code here, so others (including me) can use it.
Thanks, Hermann
shiftLock happens
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Fri Apr 15, 2016 7:30 pm
Hi all - this is a version of what is in Guide that compiles and runs for me (i.e. with capitalised "Real", without "as undefined" - and also without Peter's tweak for it's width and height)
Code: Select all
widget community.livecode.beaumont.pinkCircle
metadata title is "My Pink Circle"
metadata author is "Benjamin Beaumont"
metadata version is "1.0.0"
use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
// Properties
property circleMargin get mMargin set setMargin
// Local variables
private variable mMargin as Real
public handler onCreate()
put 0 into mMargin
end handler
public handler OnPaint()
// Create a path with a radius of half the width of the canvas
// Set the paint to a solid pink color
// Fill the path
variable tCirclePath as Path
put circle path centered at point [my width / 2, my height / 2] with radius ((my width - mMargin)/2) into tCirclePath
set the paint of this canvas to solid paint with color [1, 0, 1]
fill tCirclePath on this canvas
end handler
public handler setMargin(in pMargin as Real)
put pMargin into mMargin
redraw all
end handler
end widget
"...this is not the code you are looking for..."