|
|
|
Re: Can't access right-click menu items of project that have sub-menus [message #533006 is a reply to message #532985] |
Tue, 11 May 2010 19:32 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
On 5/11/10 11:34 AM, Jeff Johnston wrote:
> Interestingly enough, "New" was missing. The first item found was "Go
> Into" which should be the 2nd item after "New". Also missing were "Build
> Configurations", "Make Targets", and "Index" which are all C/C++
> specific items that have visibility dependent on project nature. The
> list had 110 entries, but a vast majority of them had a toString of
> "MenuItem {*Disposed*}". The remainder were shown as "MenuItem {*Wrong
> thread*}". Those Wrong Thread items were the ones that expanded to
> meaningful items with text. Not sure if the toString info is helpful,
> but I included it just in case.
Try printing them as you find them. The menu traversal is depth first,
the menu is opened, traversed, and closed and traversal moves to the
next menu.
Closing the menu may (*cough*) dispose items within it depending on the
platform and version of eclipse you're on(*cough*).
SWTBot currently traverses the entire menu, grabs what the matcher
matches and performs click on them, but it may be too late because the
menu is disposed.
It's ugly but that was the cheap way to build it at the time when it was
built :(
The /right way/ would be to use with some ActionMatcher that uses a
ClickRunnableAction along with a real matcher to perform an action
before the menu is closed:
menuFinder.perform(action, matcher){
// keep traversing
if (matcher.matches(menuItem)){
action.perform();
}
//
}
--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05571 seconds