Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread ComponentAt(X, Y)
Thu, Dec 5 2013 8:46 AMPermanent Link

Matthew Jones

Is there a way to take arbitrary coordinates and get a component at that position?

/Matthew Jones/
Thu, Dec 5 2013 9:23 AMPermanent Link

E.B

Using component.Left and component.Top  ....

(as first approximation !)

Eric


(Matthew Jones) wrote:

Is there a way to take arbitrary coordinates and get a component at that position?

/Matthew Jones/
Thu, Dec 5 2013 11:16 AMPermanent Link

Matthew Jones

Indeed, I presume it would have to walk the tree of components, but I wonder if it
is already done in the framework.

As it happens, I realised that the items I wanted are on a particular panel, and
all the same height, so, taking into consideration ScrollTop, I can do a simple
division to find out which one. I'd still like to know for the future though.

/Matthew Jones/
Sat, Dec 7 2013 8:32 AMPermanent Link

E.B

Well ... With Delphi I used component[i] and componentcount to explore my form's components. But I don't know if the same function exists with EWB. I don't thinck.



(Matthew Jones) wrote:

Indeed, I presume it would have to walk the tree of components, but I wonder if it
is already done in the framework.

As it happens, I realised that the items I wanted are on a particular panel, and
all the same height, so, taking into consideration ScrollTop, I can do a simple
division to find out which one. I'd still like to know for the future though.

/Matthew Jones/
Mon, Dec 9 2013 6:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eric,

<< Well ... With Delphi I used component[i] and componentcount to explore my
form's components. But I don't know if the same function exists with EWB. I
don't thinck. >>

These properties are also available, but will include non-visual components
also.  A better option are the Controls and ControlCount properties, which
are based upon parentage, not ownership:

http://www.elevatesoft.com/manual?action=viewcomp&id=ewb1&comp=TContainerControl

Tim Young
Elevate Software
www.elevatesoft.com


Mon, Dec 9 2013 6:40 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Is there a way to take arbitrary coordinates and get a component at that
position?  >>

Are you doing so in response to a mouse event, or something else ???

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Dec 10 2013 7:29 AMPermanent Link

Matthew Jones

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:
> Are you doing so in response to a mouse event, or something else ???

Mainly mouse, but not always. Depends how deep I am. I have code to
traverse the local sender to parents, but a more generic routine that is
efficient may be better. Of course generic and efficient are probably
opposed.

--
Matthew Jones
Wed, Dec 18 2013 8:17 AMPermanent Link

Matthew Jones

It is worth saying that Tim is a genius, and he provided a much better way to do
what I was wanting.

My code has an array of TPanels that contain a number of other components. From any
of those components I may have an event, and need to work out which of my internal
data objects it relates to. Thus I was having a MyPanel.MouseMove, and working out
that this was the third panel in the list, and thereby know that it is the third in
my object list. Fiddly, and perhaps slow.

The better way of course is to use the EWB TComponent "Data" property, to store a
reference to the internal data object for each of the panels etc. Thus the
MouseMove is able to go straight to the relevant object, no lookup needed, and do
the work.

How I missed this before I don't know. Probably still stuck in the Delphi mindset
where all you have is Tag.

/Matthew Jones/
Thu, Dec 19 2013 2:33 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< It is worth saying that Tim is a genius, and he provided a much better
way to do what I was wanting. >>

I like where you're going there.... Wink

<< The better way of course is to use the EWB TComponent "Data" property, to
store a reference to the internal data object for each of the panels etc.
Thus the MouseMove is able to go straight to the relevant object, no lookup
needed, and do the work. >>

Nicely done. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Image