Emulate the Clicking of a Menu Item?

Hi Folks - my user needs to move from formA to formB with a particular record already pre-selected in formB.

Typically to get to formB the user would select a menu option (our own menu not a Servoy menu item BTW) which runs code to highlight the menu choice and indicate where the user is in a sub menu too. The code for that is in the menu onAction using a getMethodTriggerElementName.

I have the record selection taken care of, and I can show the relevant form - but - is there a way to simulate / emulate the clicking of that particular menu element? There are two reasons to want to do it this way:

  1. I need the form to be seen in its proper context - and since its nested in various tabs I need to code to move to that tab index-nesting, rather than show it in a dialog etc.

  2. The user experience is consistent in terms of what he sees on the menus, when in various parts of the system.

Obviously I cant simply run the onAction event code - as that will not indicate the element name, even if I could see how to do that!

Is this possible to simulate this element onAction event, or do I need to devise code to do each step (select the primary menu element and set its colour etc, show the form in its nested context, set the submenu colouring too)?

Appreciate comments.??

Possible???

Kahuna:
Is this possible to simulate this element onAction event

Do I understand you correct that you are saying you just want the element name to be passed on, but you are not triggering the method from an element?

I’d say change you method to start of with something like this:

var _elementName = arguments[0];
if(!_elementName) _elementName = application.getMethodTriggerElementName();

Now you will be able to pass the elementname as an argument, and if you don’t (when clicking an element) it will get the element name from the function…

Hope this helps

Marc - I want to simulate the actual element (menu selection) being clicked - so all the functions in the onAction of that element (including its element name) are run -does that make sense???

Hi Ian,

So there’s more that you read from the element beside it’s name?
Unfortunately there’s no way to simulate a click.

I guess you have to work with those parameters in the same way, so: instantiate arguments and when they aren’t set, deal with them ‘the old way’…

Another solution is to work with arguments all the time. This means that clicking the actual element should execute a ‘preClick’ method that will gather all the arguments you need and pass those to the main method.

Thanks Marc- that give me the route to follow.

Cheers

Ian

Kahuna:
Thanks Marc- that give me the route to follow.

Cheers

Ian

Hi Ian!

That’s a very weird requirement you have here, but if you don’t find an easy way around it like Marc is advising, maybe you could take a look at the java.awt.Robot class to simulate an action?

ptalbot:
That’s a very weird requirement you have here

No change there then eh… :wink:

I’m gona put it to one side Patrick, as its a ‘nice to have’ at the moment - I’ll come back to it when I’ve gotten the other priorities out of the way. I think I can code around it relatively easily but it means a revamp of the onAction I have currently.

But I’ll take a look at that java class before I do.

Thanks as always.