That's a cool solution. I'll try it now. Thanks a lot Kevin.

Chris

On 09/18/2012 04:15 PM, Kevin Meixner wrote:
I posted my solution to Stack Overflow just a few minutes after Raju posted his:

http://stackoverflow.com/questions/12482915/is-it-possible-to-have-a-while-loop-connected-to-the-mouseover-state-in-an-openl/12484208#12484208

Here is my solution using delegates with the application Idle event:

<canvas width="1000" height="665" debug="true">

<view id="v" bgcolor="0xcccccc" width="200" height="200">

<!--- @param boolean mouseisover: true when the mouse is over -->
<attribute name="mouseisover" type="boolean" value="false" />

<!--- @keywords private -->
<!--- @param lz.Delegate dlgt_repeat: stores the lz.Delegate object -->
<attribute name="dlgt_repeat" type="expression" />

<!--
    Called when the 'onmouseover' event occurs
    -->
<handler name="onmouseover">

      // Step 1) unregister any existing delegate
      // mark it for garbage collection
      // and prevent its event from triggering:

      if (this['dlgt_repeat'])
        this.dlgt_repeat.unregisterAll();

      // Step 2) update this.mouseisover flag:

      if (!this.mouseisover)
        this.setAttribute('mouseisover', true);

      // Step 3) create an event Delegate and call it
      // on the next application idle event:

      var objDlgt = new lz.Delegate(this, 'doSomething');
      this.setAttribute('dlgt_repeat', objDlgt);

      lz.Idle.callOnIdle(this.dlgt_repeat);

</handler>

<!--
    Called when the 'onmouseout' event occurs
    -->
<handler name="onmouseout">

      // Step 1) unregister any existing delegate
      // mark it for garbage collection
      // and prevent its event from triggering:

      if (this['dlgt_repeat'])
        this.dlgt_repeat.unregisterAll();

      // Step 2) Update this.mouseisover flag:

      if (this.mouseisover)
        this.setAttribute('mouseisover', false);

</handler>

<!--- @keywords private -->
<!---
    @param ??? objDummy: required for SWF9+ run-times due to
    AS3 (ActionScript3 compiler requirements)
    -->
<method name="doSomething" args="objDummy=null">
<![CDATA[

      // Note: CDATA allows '&&' to be used in script below,
      // alternatively omit CDATA and use '&amp;&amp;' instead
      // of '&&'

      // Step 1) Execute your code you want to run here:
      if ($debug) Debug.debug('Do something...');

      // Step 2): If mouse is still over and the event
      // delegate exists then schedule the event to be
      // executed upon the next application idle state:

      if (this.mouseisover && this['dlgt_repeat'] != null)
        lz.Idle.callOnIdle(this.dlgt_repeat);

    ]]>
</method>

<text text="Move mouse over" />

</view>

</canvas>


On 9/18/2012 3:00 PM, [email protected] wrote:
Send Laszlo-user mailing list submissions to
    [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
    http://www.openlaszlo.org/mailman/listinfo/laszlo-user
or, via email, send a message with subject or body 'help' to
    [email protected]

You can reach the person managing the list at
    [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Laszlo-user digest..."


Today's Topics:

    1. Testing for mouse events (Chris Janik)


----------------------------------------------------------------------

Message: 1
Date: Tue, 18 Sep 2012 13:03:31 -0400
From: Chris Janik<[email protected]>
Subject: [Laszlo-user] Testing for mouse events
To: [email protected]
Message-ID:<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Is it possible to do something like this

while (view.mouseover == true) {
      preform action
}

I want to have an action repeat for as long as the mouse is over a
specific view.




Reply via email to