Unfortunately, you can't declare event handlers that way. WTKXSerializer expects an actual named function for each event handler method you want to define.

I think the best way to reduce the amount of script code would be via the attribute-based event handlers we have discussed adding.


On Sep 16, 2009, at 3:31 PM, Vicente de Rivera III wrote:

Hi, I have a followup question about action listeners in wtkx. Right now I have,
      "
                 <PushButton buttonData="Logout">
<buttonPressListeners>
                                                        <wtkx:script>
                                                         <![CDATA[

function buttonPressed(button) {

application.doSwitch(0);
                                                                }
                                                         ]]>
                                                        </wtkx:script>
</ buttonPressListeners>
                                                </PushButton>
<PushButton buttonData="Home"> <buttonPressListeners>
                                                        <wtkx:script>
                                                         <![CDATA[

function buttonPressed(button) {

application.doSwitch(1);
                                                                }
                                                         ]]>
                                                        </wtkx:script>
</ buttonPressListeners>
                                                </PushButton>
  "
I'd like to reduce this to a single var, I tried defining
  "
                  <wtkx:script>
                    var doNav = function(idx){
                        return function buttonPressed(button) {
                           application.doSwitch(idx);
                        }
                     };
                 </wtkx:script>
   "
then call, $doNav() for both PushButton but it doesn't work.
Any way to reduce my script?

thanks!
-
thirdy

Reply via email to