Testing the Widget
Now we have completed the OnPaint handler we are ready to test the widget.
This is the full code of the widget, so far.
widget community.livecode.elanorb.rotatedtext use com.livecode.canvas use com.livecode.widget use com.livecode.engine use com.livecode.library.widgetutils metadata title is "Rotated Text" metadata author is "Elanor Buchanan" metadata version is "1.0.0" private variable mRotation as Number property "rotation" get mRotation set setRotation public handler OnPaint()      variable tText as String      variable tWidth as Real      variable tHeight as Real      put my width into tWidth      put my height into tHeight      put "LiveCode" into tText      rotate this canvas by mRotation      variable tRectangle as Rectangle      variable tPath as Path      put rectangle path of rectangle [0,0,tWidth,tHeight] into tPath      rotate tPath by (mRotation * -1)      put the bounding box of tPath into tRectangle      fill text tText at center of tRectangle on this canvas      end handler public handler setRotation(in pRotation as Number) returns nothing     put pRotation into mRotation     redraw all end handler end widget
Just like a library we compile, test, package and install widgets using the Extension Builder.
- Open the Extension Builder from the Tools menu.
- Click the Open button.
- Load the ‘rotatedtext.lcb’ file.
To test the widget click the Test button.
This will create a stack in the IDE with a Rotated Test widget on it.
- Go into Edit mode.
- Select the widget.
- Open the Property Inspector.
- Set the Rotation property.