How do I find out if the content assist popup window is currently showing? [message #514044] |
Fri, 12 February 2010 04:51  |
Eclipse User |
|
|
|
I am implementing a text editor that is closed when ESC is pressed. But
if the content assist popup window is showing, ESC should only close
this popup.
The main problem is that the
org.eclipse.jface.text.contentassist.CompletionProposalPopup .verifyKey(VerifyEvent)
returns true when ESC is pressed, thus handing the key event through to
the KeyListener that closes the editor.
My current workaround is a combined VerifyKeyListener / KeyListener that
sets a flag in verifyKey() if ESC is pressed and
ContentAssistant.hasProposalPopupFocus() returns true. If the flag is
set, the keyPressed() method ignores the next ESC. But that ugly
workaround only works if the popup is *focussed*.
I cannot add another IContentAssistListener to the ContentAssistant that
returns false in this case, as the add method is package private. I
guess that'd be a problem anyway, as I cannot make sure in which order
the IContentAssistListeners are registered / executed.
Any ideas?
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
Re: How do I find out if the content assist popup window is currently showing? [message #514117 is a reply to message #514044] |
Fri, 12 February 2010 08:32  |
Eclipse User |
|
|
|
Jan Koehnlein wrote:
> I am implementing a text editor that is closed when ESC is pressed.
> But if the content assist popup window is showing, ESC should only
> close this popup.
>
> The main problem is that the
> org.eclipse.jface.text.contentassist.CompletionProposalPopup .verifyKey(VerifyEvent)
>
> returns true when ESC is pressed, thus handing the key event through
> to the KeyListener that closes the editor.
>
> My current workaround is a combined VerifyKeyListener / KeyListener
> that sets a flag in verifyKey() if ESC is pressed and
> ContentAssistant.hasProposalPopupFocus() returns true. If the flag is
> set, the keyPressed() method ignores the next ESC. But that ugly
> workaround only works if the popup is *focussed*.
>
> I cannot add another IContentAssistListener to the ContentAssistant
> that returns false in this case, as the add method is package private.
> I guess that'd be a problem anyway, as I cannot make sure in which
> order the IContentAssistListeners are registered / executed.
>
> Any ideas?
You don't need to implement closing on 'Esc'. Simply assign 'Esc' to the
Close command and all works as expected.
Dani
|
|
|
Powered by
FUDForum. Page generated in 1.05606 seconds