Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Clicking on menu Eclipse in Mac OSX
Clicking on menu Eclipse in Mac OSX [message #1470446] Wed, 12 November 2014 10:43 Go to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 83
Registered: May 2013
Member
Hi,

I managed already to click on the "File" menu, but it seems that menu "Eclipse", the one just next to the Apple icon, is not a typical menu.

This code doesn't work for this menu:

private static SWTWorkbenchBot bot = new SWTWorkbenchBot();
bot.menu("Eclipse").menu("Preferences...").click();


Any idea how to access this menu ?

thanks,
BenoƮt
Re: Clicking on menu Eclipse in Mac OSX [message #1532069 is a reply to message #1470446] Sat, 27 December 2014 20:43 Go to previous messageGo to next message
Andrew Holland is currently offline Andrew HollandFriend
Messages: 1
Registered: December 2014
Junior Member
Theres no way to access the Application Menu using standard SWTBot API, i had tried to extend SWTBot to support the Application Menu but found a bug in the process.

To access the menu you need to call

Display display = ....
Menu appMenu = display.getSystemMenu()


You will be using the set widget directly, so will need to synchronise with the ui thread.

a1dutch
Re: Clicking on menu Eclipse in Mac OSX [message #1538762 is a reply to message #1532069] Wed, 31 December 2014 14:52 Go to previous message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 83
Registered: May 2013
Member
Thanks a lot Andrew for the hint !

For sake of completeness, below the full code which worked in my case.

------------------------------------------------------------------------------------------------
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window != null) {
Menu appMenu = workbench.getDisplay().getSystemMenu();
for (MenuItem item : appMenu.getItems()) {
if (item.getText().startsWith("Preferences")) {
Event event = new Event();
event.time = (int) System.currentTimeMillis();
event.widget = item;
event.display = workbench.getDisplay();
item.setSelection(true);
item.notifyListeners(SWT.Selection, event);
break;
}
}
}
}
});

[Updated on: Wed, 31 December 2014 14:53]

Report message to a moderator

Previous Topic:Seletion on Nebula gridview
Next Topic:select 2 nodes of tree SWTbot
Goto Forum:
  


Current Time: Mon Sep 24 15:59:55 GMT 2018

Powered by FUDForum. Page generated in 0.03499 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top