context click pixel offsets wrong for MS-Windows XUL client

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

context click pixel offsets wrong for MS-Windows XUL client

mixit
or rather, I should say, they MAY be wrong:

I have a scrolling tree 10 columns and column headers with a context
menu attached.
I have a function that checks the location of the context mouse-click
and enables/disables
various menu items in the context menu depending on the nature of the
cell/column/row clicked on, acquiring the cell details using
treeBoxObject.getCellAt()

The standard mechanism for accessing the mouse position would be:

var mX = popupevent.clientX - tree.boxObject.x
var mY = popupevent.clientY - tree.boxObject.y

but in this instance, the Y-coordinates of the context click are out
by 23 pixels (precisely the height of the tree column head).

I have examined all the following variables to see if there is some
other way of getting the right values but have found nothing useful,
no matter what math I do:
popupevent.clientX
popupevent.clientY
popupevent.layerX
popupevent.layerY
popupevent.pageX
popupevent.pageY
tree.boxObject.x
tree.boxObject.y
tree.boxObject.screenX
tree.boxObject.screenY
tree.body.boxObject.x
tree.body.boxObject.y
tree.body.boxObject.screenX
tree.body.boxObject.screenY

Can somebody advise me if there is a way to get the absolutely correct
Y-coordinate of the context click?

or is this a bug?

_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: context click pixel offsets wrong for MS-Windows XUL client

Neil Deakin
mixit wrote:

> or rather, I should say, they MAY be wrong:
>
> I have a scrolling tree 10 columns and column headers with a context
> menu attached.
> I have a function that checks the location of the context mouse-click
> and enables/disables
> various menu items in the context menu depending on the nature of the
> cell/column/row clicked on, acquiring the cell details using
> treeBoxObject.getCellAt()
>
> The standard mechanism for accessing the mouse position would be:
>
> var mX = popupevent.clientX - tree.boxObject.x
> var mY = popupevent.clientY - tree.boxObject.y
>
> but in this instance, the Y-coordinates of the context click are out
> by 23 pixels (precisely the height of the tree column head).
>

You should just be passing clientX and clientY directly to getCellAt.

/ Neil
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: context click pixel offsets wrong for MS-Windows XUL client

mixit
On Jul 10, 2:14 pm, Neil Deakin <[hidden email]> wrote:

> mixit wrote:
> > or rather, I should say, they MAY be wrong:
>
> > I have a scrolling tree 10 columns and column headers with a context
> > menu attached.
> > I have a function that checks the location of the context mouse-click
> > and enables/disables
> > various menu items in the context menu depending on the nature of the
> > cell/column/row clicked on, acquiring the cell details using
> > treeBoxObject.getCellAt()
>
> > The standard mechanism for accessing the mouse position would be:
>
> > var mX = popupevent.clientX - tree.boxObject.x
> > var mY = popupevent.clientY - tree.boxObject.y
>
> > but in this instance, the Y-coordinates of the context click are out
> > by 23 pixels (precisely the height of the tree column head).
>
> You should just be passing clientX and clientY directly to getCellAt.
>
> / Neil

Thanks, Neil, unfortunately I tried this as well - it is still 23
pixels out :(
I'm been driving myself batty trying to account for the offset but
both in my applications and my test case, I get the same un-accounted
for offset.
I shall put the testcase up this evening for all to view.

_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: context click pixel offsets wrong for MS-Windows XUL client

DDD-3
On Jul 10, 10:03 pm, mixit <[hidden email]> wrote:

> On Jul 10, 2:14 pm, Neil Deakin <[hidden email]> wrote:
>
>
>
>
>
>
>
> > mixit wrote:
> > > or rather, I should say, they MAY be wrong:
>
> > > I have a scrolling tree 10 columns and column headers with a context
> > > menu attached.
> > > I have a function that checks the location of the context mouse-click
> > > and enables/disables
> > > various menu items in the context menu depending on the nature of the
> > > cell/column/row clicked on, acquiring the cell details using
> > > treeBoxObject.getCellAt()
>
> > > The standard mechanism for accessing the mouse position would be:
>
> > > var mX = popupevent.clientX - tree.boxObject.x
> > > var mY = popupevent.clientY - tree.boxObject.y
>
> > > but in this instance, the Y-coordinates of the context click are out
> > > by 23 pixels (precisely the height of the tree column head).
>
> > You should just be passing clientX and clientY directly to getCellAt.
>
> > / Neil
>
> Thanks, Neil, unfortunately I tried this as well - it is still 23
> pixels out :(
> I'm been driving myself batty trying to account for the offset but
> both in my applications and my test case, I get the same un-accounted
> for offset.
> I shall put the testcase up this evening for all to view.
http://www.xulplanet.com/tutorials/xultu/advevents.html

All mouse events will be supplied with properties that hold the
coordinates of the mouse position where the event occured. There are
two sets of coordinates. The first is the screenX and screenY
properties and are relative to the top left corner of the screen. The
second set, clientX and clientY, are relative to the top left corner
of the document.

I thought that your tree may be at the top of the document. And you
could get  the height of treecol according to the boxObject of
<treecols>, but not 23 pixels.

_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: context click pixel offsets wrong for MS-Windows XUL client

mixit
On Jul 10, 3:55 pm, "[hidden email]" <[hidden email]> wrote:

> On Jul 10, 10:03 pm, mixit <[hidden email]> wrote:
>
> > On Jul 10, 2:14 pm, Neil Deakin <[hidden email]> wrote:
>
> > > mixit wrote:
> > > > or rather, I should say, they MAY be wrong:
>
> > > > I have a scrolling tree 10 columns and column headers with a context
> > > > menu attached.
> > > > I have a function that checks the location of the context mouse-click
> > > > and enables/disables
> > > > various menu items in the context menu depending on the nature of the
> > > > cell/column/row clicked on, acquiring the cell details using
> > > > treeBoxObject.getCellAt()
>
> > > > The standard mechanism for accessing the mouse position would be:
>
> > > > var mX = popupevent.clientX - tree.boxObject.x
> > > > var mY = popupevent.clientY - tree.boxObject.y
>
> > > > but in this instance, the Y-coordinates of the context click are out
> > > > by 23 pixels (precisely the height of the tree column head).
>
> > > You should just be passing clientX and clientY directly to getCellAt.
>
> > > / Neil
>
> > Thanks, Neil, unfortunately I tried this as well - it is still 23
> > pixels out :(
> > I'm been driving myself batty trying to account for the offset but
> > both in my applications and my test case, I get the same un-accounted
> > for offset.
> > I shall put the testcase up this evening for all to view.
>
> http://www.xulplanet.com/tutorials/xultu/advevents.html
>
> All mouse events will be supplied with properties that hold the
> coordinates of the mouse position where the event occured. There are
> two sets of coordinates. The first is the screenX and screenY
> properties and are relative to the top left corner of the screen. The
> second set, clientX and clientY, are relative to the top left corner
> of the document.
>
> I thought that your tree may be at the top of the document. And you
> could get  the height of treecol according to the boxObject of
> <treecols>, but not 23 pixels.

yeah - I know what the different coordinate sets are, and what they
relate to.
Getting the boxobject height of the <treecols> doesn't help me in
identifying this 23 pixels though :(
Once I post the testcase this evening, you can see what I mean.

_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul