Hi,
Perhaps this is a noob misunderstanding - but the following is the simplest
script I
could muster that shows the issue.

The intent is to instantiate an element on a mouse click, at the position of
the mouse click.
I am having trouble deciphering the difference between the global and local
mouse events.

Within the window in the script below, x=0,y=0 seems to be indexed of the
window area accounting for the border.
However, the canvas_click and local_click are essentially at the same point.


The issue with this is that the local_click and canvas_click are being
instantiated offset by the title bar height and
border wrt the actual mouse click.

Would this be a bug or am I doing something wrong?
Any help is much appreciated.

I am using the 4.0.7 SDK to build this.

thanks,
-shishir


<canvas debug="true">
  <handler name="onclick" reference="LzGlobalMouse">
    Debug.write('Global onclick x:' + canvas.getMouse('x') + ' y:' +
canvas.getMouse('y'));
  </handler>

  <class name="myshow" extends="inputtext">
  </class>

  <window name="mywindow" x="1" width="25%" height="25%" clickable="true">
    <handler name="onclick">
      var local_zero = new myshow (mywindow, { x:"0", y:"0", width:"10",
height:"10", bgcolor:"0xff0000"});
      var canvas_click = new myshow (mywindow, { x:canvas.getMouse('x'), y:
canvas.getMouse('y'),
                               width:"12", height:"12",
bgcolor:"0x00ff00"});
      var local_click = new myshow (mywindow, { x:mywindow.getMouse('x'), y:
mywindow.getMouse('y'),
                               width:"10", height:"10",
bgcolor:"0x0000ff"});
      Debug.write('Local onclick canvas_click(green) x:' + canvas_click.x +
' y:' + canvas_click.y +
                              '; local_click(blue) x:' + local_click.x + '
y:' + local_click.y);
    </handler>
  </window>
</canvas>

Reply via email to