Programatically open a menu from menubar [message #938884] |
Wed, 10 October 2012 08:37 |
Somesh Rathi Messages: 7 Registered: August 2012 |
Junior Member |
|
|
Hello,
MenuManager and Menu Contribution items has been already created.
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.
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());
if(toCompare.equalsIgnoreCase(menuText)){
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);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03715 seconds