User Tools

Site Tools


pracro:devas_corner

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
pracro:devas_corner [2010/08/02 14:20] devapracro:devas_corner [2010/08/10 10:49] deva
Line 5: Line 5:
 <?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
 <macro name="test_resume" version="1.0"> <macro name="test_resume" version="1.0">
 +
 +  <resume>
 +    <script src="regexp.lua"/>
 +    <script>
 +      -- inline code
 +      if(regexp('.+', ''))
 +      then
 +        return 'a string'
 +      else
 +        return 'another string'
 +      end
 +    </script>
 +  </resume>
 +
   <script>   <script>
     function foo()     function foo()
       -- this: current widget (widget that triggered the event)       -- this: current widget (widget that triggered the event)
-      -- this.value: current value 
-      -- this.name: current name 
-      -- this.type: current type (eg. 'checkbox') 
  
       this.setChecked(true)       this.setChecked(true)
Line 16: Line 27:
       foo = getWidgetByName('test2')       foo = getWidgetByName('test2')
  
-      if ( foo && foo.type == 'lineedit' )+      if ( foo && foo.getType() == 'lineedit' )
       then       then
          foo.setValue('bleh')          foo.setValue('bleh')
Line 46: Line 57:
  
 ====Event Handlers==== ====Event Handlers====
-''onChange'': triggered whenever the value of the widget is changed, either programmatically or by the user.\\ +  * ''onChange'': triggered whenever the value of the widget is changed, either programmatically or by the user. 
-''onUserChange'': triggered whenever the value of the widget is changed by the user.\\+  ''onUserChange'': triggered whenever the value of the widget is changed by the user. 
 +  * and many more
  
 +====The Widget Object====
 +When in a lua function, invoked by an event handler, the calling object (the object invoking the event) will be made available through the value 'this'.
 +Other object can be retrieved using the ''getWidget('name')'' function.
 +<code lua>
 +function foo()
 +   if (this.value == 'bar')
 +   then
 +      this.setValue('dut')
 +   end
 +
 +   bas = getWidget('mywdg')
 +   if (bas && bas.value == 'bar' )
 +   then
 +      bas.setValue('dims')
 +   end
 +end
 +</code>
 +A small number of methods are common to all widget types. These include are:
 +  * ''set/getValue''
 +  * ''set/getValid''
 +  * ''set/getVisible''
 +  * ''set/getEnabled''
 +  * ''getType''
 +  * ''getName''
 +Others are specific to certain widget types, such as (and many more):
 +  * ''set/getChekced'' (checkbox)
 +  * ''set/getSelection'' (listbox)
 +  * ''set/getCarriagePosition'' (lineedit)
  
 =====New protocol===== =====New protocol=====
Line 170: Line 210:
 A macro in resume mode is marked with a distinct colour when committed.\\ A macro in resume mode is marked with a distinct colour when committed.\\
 A macro already committed, and reopened, is to be opened in edit mode, ie. it is to assume the old values from the commit. A macro already committed, and reopened, is to be opened in edit mode, ie. it is to assume the old values from the commit.
- 
- 
pracro/devas_corner.txt · Last modified: 2011/01/14 14:49 by deva