Delphi popup menu?
- 10 years ago
** FINAL UPDATE **
OK. I have it working now.
Was not able to use the index. Even with three levels of menu open (all of type "Popup") they all report an index of 1 and it always finds the first level container? No idea why. But thats what was happening.
So, I ended up using the "Name" property. As each new level container is spawned, it's name appears to be dynamically generated based on the selection prior to it. With the first level always having the name "Context".
So to find each level, I search for a container of type "Popup" with "Name" properties of:
Level 1 - ["Popup"]("Context") - pre-populated
Level 2 - ["Popup"]("Level 1 selection text") - Selection text based on the user input
Level 3 - ["Popup"]("Level 2 selextion text") - Same as above ...
And so on. For as few or many levels deep as requirted. (It's in a loop obviously) As it finds each new container, finding the MenuItem within that is simple. It hovers each one until the end and clicks on the final one if it gets through without any errors.
The containers are all direct children of the top level process so it doesn't have to search too deep. Each container then only contains a handful of MenuItem object to search through. So the speed remains good.
As each component is searched out and identified before it is used, I can validate as I go and and failed object searches will be picked up and generate the required error messages. (This is all data driven so needs to be robust in case people feed it garbage)
Very convoluted way of getting there. But got there in the end.