Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How can I check if a part is active and has the focus?
How can I check if a part is active and has the focus? [message #984182] Wed, 14 November 2012 13:28 Go to next message
Renso Lohuis is currently offline Renso LohuisFriend
Messages: 44
Registered: July 2012
Member
I would like to check if the part is active and has the focus or that a dialog above it has the focus.

This is what I have so far:
	@Inject
	protected MPart part;
	@Inject
	protected EPartService partService;

	public boolean isActiveAndHasFocus() {
		return part == partService.getActivePart();
	}


But I don't see any difference if there is a dialog above it (the part will still be active when a dialog shown above it.)

Is there a way to check if the part is active without any dialog above it?


Re: How can I check if a part is active and has the focus? [message #985284 is a reply to message #984182] Thu, 15 November 2012 09:26 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot CelaFriend
Messages: 597
Registered: December 2010
Senior Member

What about getting the swt composite of the part MPart#getWidget() and seeing if it has SWT focus?
Re: How can I check if a part is active and has the focus? [message #986001 is a reply to message #985284] Sat, 17 November 2012 10:52 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 194
Registered: January 2012
Senior Member

Check if the window is active. We might set some a tag on the window to indicate this but otherwise you can test the widget (a shell).

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Add menu item to menu at runtime
Next Topic:Theme for Eclipse Juno - Images
Goto Forum:
  


Current Time: Sat Nov 29 06:37:23 GMT 2014

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

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