Canvas
Posted: Thu Aug 02, 2018 3:42 pm
Hello,
I'm struggled with Canvas. After 2 years no real documentation so I'm wandering in the dark.
I tried this widget, but I get an empty widget, what's wrong?
I'm struggled with Canvas. After 2 years no real documentation so I'm wandering in the dark.
I tried this widget, but I get an empty widget, what's wrong?
Code: Select all
widget com.livecode.widget.testmax
-- proviamo un semplice test
--Libraries
use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
use com.livecode.logic
--Metadata
metadata title is "Test Text"
metadata author is "Massimiliano Vessi"
metadata version is "0.0.1"
metadata svgicon is "M1123 1409L1123 1228Q1035 1284 949 1284 898 1284 861 1261 832 1244 822 1216 811 1186 811 1087L811 792 1085 792 1085 611 811 611 811 320 647 320Q636 410 607 467 578 524 529 566 481 606 413 629L413 792 540 792 540 1196Q540 1274 557 1317 574 1359 616 1395 659 1432 720 1452 782 1472 860 1472 927 1472 989 1458 1046 1445 1123 1409ZM1536 416L1536 1376Q1536 1495 1451.5 1579.5 1367 1664 1248 1664L288 1664Q169 1664 84.5 1579.5 0 1495 0 1376L0 416Q0 297 84.5 212.5 169 128 288 128L1248 128Q1367 128 1451.5 212.5 1536 297 1536 416Z"
--Properties
property theText get gText set setText
metadata theText.editor is "com.livecode.pi.string"
metadata theText.label is "The text to show"
metadata theText.default is "Ciao!"
--Variables
private variable gText as String
private variable mTextPaint as Paint
--handlers
--handler onCreate()
-- put "The text to show" into mText
--end handler
handler OnPaint()
put solid paint with color [1,1,1] into mTextPaint
set the paint of this canvas to mTextPaint
set the font of this canvas to font "FreeSans" at size 12
fill text gText at point [0,12] on this canvas
end handler
private handler setText(in pText as String)
put pText into gText
end handler
handler onSave(out rProperties as Array)
put the empty array into rProperties
put gText into rProperties["theText"]
end handler
handler OnLoad(in pProperties as Array)
put pProperties["theText"] into gText
end handler
end widget