PDA

View Full Version : can not capture event using LzTrack


haplo
07-08-2007, 08:33 PM
what i'm doing wrong here? i'm trying to catch events using LzTrack for a sub view inside a window, am i missing something basic here?


<canvas debug="true">
<class name = "testWindow" extends="window" width="100" height="100" resizable="true">
<attribute name="__istest" value="true"/>
<view bgcolor="green" name="container" height="${parent.height/2}" width="${parent.width/2}"/>

</class>


<testWindow name="blueWindow" x="200" bgcolor="blue"/>



<view name="dragItem" width = "20" height="20" bgcolor = "green" visible="true">

<handler name="onmousetrackover" reference="parent.blueWindow.container">
Debug.write("ohh i'm feeling blue")
</handler>

<dragstate name="dragger"/>


<handler name="oninit">
this.del = new LzDelegate(this,'remove');
this.del.disable();
this.del.register(LzGlobalMouse,'onmouseup');
</handler>


<method name="apply" event="onmousedown"><![CDATA[
var subs = parent.getDepthList();
for ( var i=0; i < subs.length; i++ ) {
if ( subs[i] && subs[i].getAttribute && subs[i].getAttribute('__istest') ) {
Debug.write(this, 'registering', subs[i]);
LzTrack.register(subs[i].container,'myTrackGroup');
}
}

this.bringToFront();
this.dragger.apply();
LzTrack.activate('myTrackGroup');
this.del.enable();
]]></method>

<method name="remove">
this.del.disable();
this.dragger.remove();
LzTrack.deactivate('myTrackGroup');
</method>
</view>


</canvas>

senshi
07-09-2007, 10:35 AM
i'm trying to catch events using LzTrack for a sub view inside a window, am i missing something basic here?


If I drag the little green view ("dragItem") and then move the mouse, while still dragging, over the other green view ("container"), the debug-output "ohh i'm feeling blue" is printed.
What do you see in your application resp. what do you want to see?

haplo
07-11-2007, 07:25 AM
you do?
i'm still using openlaszlo 3.3.3 is that a bug there, cause i can't see the output

senshi
07-13-2007, 03:26 PM
Yes, seems to be a bug in OL3.3.3.
I've just tested this again: OL4.0.2 works as expected, OL3.3.3 doesn't.

To fix this, add this script-block at the beginning of your application.
(This is just taken from OL4.0.2)

<script><![CDATA[
LzTrack.__LZtrackgroup = function (group,hitlist) {
//check mouse pos

// this will be slow on vertical menus because
// the mouse_x will intersect with all menuitems if
// if it intersects any menuitem. We should include
// an optimise for axis attribute as part of a group.
for (var i=0; i < group.length; i++) {
var v = group[i];
if ( v.visible ) { // dont check mouse if not visible
var vx = v.getMouse('x');
if (vx > 0 && vx < v.width) { // inside width
var vy = v.getMouse('y');
if (vy > 0 && vy < v.height) { // inside height
hitlist.push(v);
}
}
}
}
}
]]></script>