how to write components with runrev, two demos
Marielle Lange
mlange at lexicall.org
Fri Apr 21 12:59:28 EDT 2006
(apologizes for cross-posting)
Dear all,
In have uploaded in my revonline folder two demos of widgets
illustrating a mvc approach to programming.
1. file download widget
The widget doesn't do anything particularly exciting (you specify a
url and a target directory and push on the download button and the
file gets downloaded.
What is of interest is the way the widget is written. The view is
completely separated from the model. The model doesn't need a view to
work. The view requires no more than a group called
"wg_file_download" with the appropriate functions on the card (could
be made invisible). There is no need to put any script in the back of
the stack. It is built-in to allow for localisation (thought I didn't
fully implement this feature yet).
2. gradient widget
This is a bit more exciting in what it does. I outline a method to
easily create using tips from "Simple Method Of Storing Colour
Ramps" (Written By Paul Bourke, June 2003; Adapted from OGLE By Dr.
Michael J. Gourlay)http://astronomy.swin.edu.au/~pbourke/colour/
ogleramp/
What is illustrated here is how such a problem can be divided into 3
main components: (1) a speadsheet object for manipulating the
gradient data and reformat, (2) a gradient creation utility that will
create a gradient from these data, and (3) a snapshot utility for
transforming the gradient into a permanent format
(in response to some comments made on the revinterop list by Richard
and others, in fact I found of little relevance to dissociate vew
from controller in this widget).
To the ones sceptical about components, I reckon that the script can
appear somehow longer than the one you would have written to solve
that problem. The interest of adding a few more lines of script the
way i did is that you can easily define the widget components (view
elements) and script parameters from outside the view. It takes more
time to write a component. But any component you write this way is
more robust (because used in multiple contexts)
Tested on a Mac only. Any feedback will be much appreciated.
Marielle
------------------------------------------------------------------
Marielle Lange (PhD), Freelance Academic
Widged http://
widged.com/
Easy access to lexical databases http://lexicall.widged.com/
Supporting Education Technologists http://revolution.widged.com/wiki/
More information about the use-livecode
mailing list