dabowebsite Commit
Revision 118
Date: 2007-10-11 18:10:43 -0700 (Thu, 11 Oct 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabowebsite/changeset/118

Changed:
A   trunk/blog/Tips/Using_raiseEvent.txt

Log:
auto-commit

Diff:
Added: trunk/blog/Tips/Using_raiseEvent.txt
===================================================================
--- trunk/blog/Tips/Using_raiseEvent.txt                                (rev 0)
+++ trunk/blog/Tips/Using_raiseEvent.txt        2007-10-12 01:10:43 UTC (rev 
118)
@@ -0,0 +1,46 @@
+Using raiseEvent()
+<p>Sometimes, even if you know the framework as well as I do, you re- 
+discover a feature that you had forgotten about. This happened  
+tonight as I was going over the interaction between a grid and its  
+form, so I thought I'd pass it along.</p>
+
+<p>    When any of the events that cause the current record pointer to move  
+are handled by the form, it generates a dEvents.RowNumChanged event,  
+to which grids can bind so that they can update their display. The  
+form code looked like:</p>
+
+<p>dabo.ui.callAfter(self.raiseEvent, dEvents.RowNumChanged)</p>
+
+<p>and the event handler in the grid would run this code:</p>
+
+<p>try:
+       self.CurrentRow = self.getBizobj().RowNumber
+except AttributeError:
+       pass</p>
+
+<p>    In other words, the grid knew that the row had changed, but had no  
+idea what the new row was. It had to then get a reference to the  
+bizobj for that grid, if any, and then ask that bizobj for its  
+current row number.</p>
+
+<p>    Why is this inefficient? Because the code that raised the event  
+*knew* the old and new row numbers; the fact that they were different  
+was why it was raising the event in the first place. Then I  
+remembered that you can pass data along to raiseEvent(); any keyword  
+parameters you add are set as event data. So I changed the form code  
+to read:</p>
+
+<p>dabo.ui.callAfter(self.raiseEvent, dEvents.RowNumChanged,
+               newRowNumber=biz.RowNumber, oldRowNumber=oldRowNum)</p>
+
+<p>...and now the grid's event handler can just reference those values  
+directly! They will have the same names as the parameter keys:</p>
+
+<p>try:
+       self.CurrentRow = evt.newRowNumber
+except AttributeError:
+       pass</p>
+
+<p>    This may be a small savings overall, but I thought that it  
+illustrated a handy mechanism built into the Dabo event class that  
+you might use to improve your applications.</p>
\ No newline at end of file


Property changes on: trunk/blog/Tips/Using_raiseEvent.txt
___________________________________________________________________
Name: svn:eol-style
   + native




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]

Reply via email to