Here's a brief rundown of what I've tried, I can use any advice about what I've missed.
set the red of the color of my background paint to 0
set the green of the color of my background paint to 1
set the blue of the color of my background paint to 0
put solid paint with color [0,1,0] into tPaint
put tPaint into my background paint
put solid paint with color [0,1,0] into tPaint
set my background paint to tPaint
put color [0,1,0] into tColor
set the color of my background paint to tColor
put color [0,1,0] into tColor
set my background paint to solid paint with tColor
Here's my experimental widget:
Code: Select all
widget pink.mad.colorexperiment
metadata title is "MPTemplate"
metadata author is "MadPink"
metadata version is "0.0.0"
metadata preferredSize is "23,42"
metadata svgicon is ""
use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
use com.livecode.foreign
use com.livecode.mathfoundation
use com.livecode.library.widgetutils
--PROPERTIES
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 "Background Color"
metadata textFont.editor is "com.livecode.pi.font"
metadata textFont.default is "Arial"
metadata textSize.editor is "com.livecode.pi.number"
metadata textSize.default is "15"
property someText get mText set setText
metadata someText.editor is "com.livecode.pi.string"
metadata someText.default is "Hello World"
metadata someText.section is "Basic"
private variable mText as String
property makeGreen get mMakeGreen set setMakeGreen
metadata makeGreen.editor is "com.livecode.pi.boolean"
metadata makeGreen.default is "false"
metadata makeGreen.label is "Make the background green"
metadata makeGreen.section is "Advanced"
private variable mMakeGreen as Boolean
private handler setMakeGreen(in pVal as Boolean)
variable tPaint as Paint
variable tCOlor as Color
put pVal into mMakeGreen
if pVal is true then
-- set the red of the color of my background paint to 0
-- set the green of the color of my background paint to 1
-- set the blue of the color of my background paint to 0
-- put solid paint with color [0,1,0] into tPaint
-- put tPaint into my background paint
-- set my background paint to tPaint
put color [0,1,0] into tColor
-- set the color of my background paint to tColor
-- set my background paint to solid paint with tColor
redraw all
end if
end handler
--HANDLERS to set properties
private handler setText(in pText as String)
put pText into mText
end handler
--SCRIPT VARIABLES
private variable mStuff as String
--HANDLERS
public handler OnCreate()
put "Hello World" into mText
end handler
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
public handler OnPaint()
variable tRect as Rectangle
set the paint of this canvas to my background paint
put rectangle [0,0,my width,my height] into tRect
fill rounded rectangle path of tRect with radius 23 on this canvas
end handler
public handler userAction()
--some sort of custom interaction
--put some data into mAppData that can be later read in the script
post "userAction"
end handler
end widget