Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Scrollbar affects Y cursor position, but how to account for it?
Sun, Sep 21 2014 11:20 PMPermanent Link

Almanac

Avatar

Hey there, I tracked down weird behavior to getting negative Y cursor positions on my images as a result of the browser window having a vertical scrollbar. Form.top nor image.top changes with the browser scroll bar, so how can I get the browser-caused displacement? Of course all I need is the cursor relative to the top left of my image control.

Thanks,
Alister.
Mon, Sep 22 2014 4:38 AMPermanent Link

Matthew Jones

Almanac wrote:

> so how can I get the browser-caused displacement?

The ScrollTop property contains the "how scrolled" value. You can also
set it to zero if you need to jump to top.

--

Matthew Jones
Mon, Sep 22 2014 7:33 PMPermanent Link

Almanac

Avatar

Hi Matthew, thanks for replying so quickly. Perhaps we have misunderstood each other.
My form does not have a scrollbar, it's the "outside" browser container that has the scrollbar.

I was thinking of a workaround trying to force the cursor to jump to 0,0 on the Timage then reading its X,Y, but that seems rather circular.

Regards,
Alister.

"Matthew Jones" wrote:

Almanac wrote:

> so how can I get the browser-caused displacement?

The ScrollTop property contains the "how scrolled" value. You can also
set it to zero if you need to jump to top.

--

Matthew Jones
Tue, Sep 23 2014 4:33 AMPermanent Link

Matthew Jones

I've not found this - the XY matches the main form, even if scrolled.
But then maybe I'm doing it differently - I tend to auto-size to the
desktop. I wasn't aware you could move the mouse from the browser, so
not sure what you are doing. But other than to say "it works for me", I
can't help further. If you have an example, perhaps that might be worth
putting together from a fresh start.

--

Matthew Jones
Wed, Sep 24 2014 12:10 AMPermanent Link

Almanac

Avatar

I shall try and re-jig the form so there are no scroll bars - a good end around to the problem - thanks Matthew.

FYI, here is a screengrab of the negative Y: https://flic.kr/p/pnnVc4; of course you can't see the mouse in the screengrab, but I positioned it a smidgen below the title bar. Note the outer vertical scrollbar is positioned so the title bar is half hidden, hence the value of FormY being -13 or -14.  It's not a big deal, it just (partially) surprised me. In Java I would retrieve the X,Y of the object's upper left corner and subtract those to get frame relative X,Y, but since java is "invisible" here in EWB, I wouldn't want to go there.

Alister.

"Matthew Jones" wrote:

I've not found this - the XY matches the main form, even if scrolled.
But then maybe I'm doing it differently - I tend to auto-size to the
desktop. I wasn't aware you could move the mouse from the browser, so
not sure what you are doing. But other than to say "it works for me", I
can't help further. If you have an example, perhaps that might be worth
putting together from a fresh start.

--

Matthew Jones
Wed, Sep 24 2014 6:47 AMPermanent Link

Matthew Jones

I've done some testing, and you are right - it is odd. I've not looked
in detail at the framework code, but I suspect that ... [fx: has a look]

Okay, the key is in TEventManager.MouseMoveHandler and in particular
where it calls FTargetControl.BodyToBaseX and
FTargetControl.BodyToBaseY. These end up in ParentToClientY which
iterates up the parents applying ScrollTop values.

It would be interesting to apply ClientToParentY to get the original
value, and then do a walk up and work out which of the parents is
"wrong". I'll leave that as an exercise for the reader who cares deeply
about it. 8-)


--

Matthew Jones
Fri, Sep 26 2014 7:31 PMPermanent Link

Almanac

Avatar

Matthew, I took your advice and simplified my interface so the scrolling never happens.

I've gone as as far as I need with my web app, so I've zipped up the project and posted it in the demos section for all to use:
http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_demos&page=1&msg=162#162

I really appreciate your help and pointers over the past few months!
Alister.
P.S. This thread can be considered at an end until someone wants to dig farther as you noted.
Image