In have uploaded in my revonline folder two demos of widgets illustrating a mvc approach to programming (Username=Marielle,category = 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)
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 in a permanent format
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
components-based approach, two demos
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
Re: components-based approach, two demos
Now also in the components section of the stacks gallerymarielle wrote:In have uploaded in my revonline folder two demos of widgets illustrating a mvc approach to programming
Or from your message box:
Code: Select all
go stack url "http://revolution.widged.com/stacks/open/components/filedownload_widget.rev"
go stack url "http://revolution.widged.com/stacks/open/components/gradient_widget.rev"
-
- Livecode Opensource Backer
Oups. Sorry about that. Now corrected and tested:malte wrote:Seems to be a broken link on your page. Browser download also fails.
go stack url "http://revolution.widged.com/stacks/ope ... widget.rev"
On the no such card, I have seen this happen with stacks that are correctly referenced (like it seems to have happened for the filedownload_widget.rev stack). Usually, clicking enter on the message box a few times does the trick. Not clear what the issue is. A guess is that the file is not fully loaded when you first press enter but is when after you try a few times.