Forums Register Login
How to Simulate the menu click in Eclipse/SWT/Jface
For the given Menu Item id , i need to programatically drop-down/open/display a menu item from menubar in eclipse. I think i may need to fire some event. Could you please help ?

I tried MenuManager.update / setVisible , however nothing showing menu programmatically.

Many thanks in advance .
Aren’t there methods like fireActionEvent? You will have to go through the documentation, starting at java.awt.Component, using ctrl-F-“event”, or the API index for F.
I'm looking here for SWT approach (to display menu programmatically) , and not the AWT. Thanks for your attention.
Need urgent help.. Thanks
Sorry for that mistake. But please remember we only use the wordurgent” on 1st April.
Sorry about that Campbell.

For the input Menu Item id/label , i need to problematically drop-down/open/display a menu item from menubar in eclipse.I think i may need to fire some event.

This is requirement for UI Automation that Menu should be drop down automatically.

Can you please help at the earliest. I'm trying following , but here not sure how to set the X & y co-ordinates where mouse click event should be fired.

Code: [Select all] [Show/ hide]

String toCompare = "File";
Menu menu = window.getShell().getMenuBar();
if(menu!=null && !menu.isDisposed()){
MenuItem[] items = menu.getItems();
for(int i=0;i<items.length;i++){
String menuText = LegacyActionTools.removeMnemonics(items[i].getText());
Event event = new Event();
event.doit = true;

event.widget = items[i];
event.type = SWT.MouseDown;
event.button = 1;

boolean success = items[i].getDisplay().post(event);
System.out.println("Could we generate the event ? "+success);
if you search this forum for SWT questions, you'll find most go unanswered.

you'd be better off posting in the SWT forum at the eclipse site.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 2283 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jun 22, 2018 09:19:09.