I have spent many hours in vain searching to find the answer. Perhaps somebody could point me to the right information.
I have created a Class which is a shape (for example a filled pentagon).
I initialize and then draw an instance, and it works fine.
I need to be able to add a Click or Touch in the Class such that if I draw 50 instances and touch one I can find via Sender or perhaps an ID or position, which one.
Thanks in advance
All the classes draw on the same View?
You will need to create an IsPointInside method in your class and then in the View's touch event you should iterate over all the shapes until you find the instance that returns True.
Thank you for responding Erel.
This is a test Class to try to learn how to do what was simple in Delphi. It draws a single shape and the main program instantiates as many instances as and where required. I do not actually believe that my fumblings have been correct but it works.
I have passed the Activity to the Class in Initialize.
In the Class I have initialized a Canvas to the Activity and then draw the shape which is much smaller than the Activity.
I am afraid that I don't know if I have done correctly because I realise that each instance will Initialize a Canvas full screen but draw on a small portion.
Perhaps this produces many layers, I don't know.
I would like to not have to scan to find the instance.
Is there therefore a way to have a smaller Canvas, just for the shape and then they all lay next to each other and each instance have a Click.
I would value further assistance please.
[EDIT] I cannot find ispointinside. I obviously need a little bigger pointer please
If I understand correctly what you want, you should create the class with an imageview as the object of the class and in the class draw on it. You also make a click sub in the class and from there you callsub to the main program, to a sub [name_of_the_bject]_click.
Now for every shape you create a new instance using the class, and each instance has its click sub in the main program, or all the instances call the same sub and you send a parameter to find which instance sent the click event.
Thank you derez, you obviously do understand correctly.
My first thought is that using an ImageView say 50 times must use a lot of resource. Maybe it is irrelevant, I don't know.
Perhaps there is an unambiguous example with an ImageView that I have been unable to find, not knowing exactly what I was looking for.
I assume the ImageView is declared within the Class.