What Object did I hit?

HI... i can't find a post helping me to find out, which object I har clicked. Say I have a 3D space of 100 object, and I Click one of them. I can always make a simpel test like

1
2
3
4
5
6
void __fastcall Form1::SomeObjectClick(TObject *Sender)
{
if (Sender == "ObjectName") 
{do something}

}


However - as I have so many Objects - I cant make such a test... I what to be able to grab the Object properties, like "Name", Position etc. If I what to grab the Name of that "unknown" Object and store it in a string, how do I do that?

Hope, someone can help.
If you can access the object sizes and locations, you can check each one in turn until you find one that contains the click location.
This looks like Borland C++ builder. As I recall SomObjectClick() will get called when the user clicks on an object of type SomeObject. Sender is the actual object clicked. Just cast it to SomeObject * and away you go.
Okay... I found out... I added the code:

TControl *Ctrl = static_cast<TControl*>(Sender);
String sName = Ctrl->Name;


Now I have the Name of the Object stored in sName… :)
Last edited on
Topic archived. No new replies allowed.