Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Simulate the menu click in Eclipse/SWT/Jface  RSS feed

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Marshal
Posts: 59108
180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 31
Eclipse IDE Hibernate Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking here for SWT approach (to display menu programmatically) , and not the AWT. Thanks for your attention.
Need urgent help.. Thanks
 
Campbell Ritchie
Marshal
Posts: 59108
180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for that mistake. But please remember we only use the wordurgent” on 1st April.
 
Somesh Rathi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
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);
}
}
>
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
My pie came with a little toothpic holding up this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!