Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Handle ESC press to a whole shell as ENTER is handled with setDefaultButton
Handle ESC press to a whole shell as ENTER is handled with setDefaultButton [message #332379] Mon, 20 October 2008 18:10 Go to next message
Marcelo Alcantara is currently offline Marcelo AlcantaraFriend
Messages: 48
Registered: July 2009
Member
Hi,

As there is a setDefaultButton in Shell/Decoration to handle ENTER on a
shell, there is a way to handle a ESC press to the whole shell too? I could
not find it anywhere.

Thanks,

Marcelo
Re: Handle ESC press to a whole shell as ENTER is handled with setDefaultButton [message #332463 is a reply to message #332379] Tue, 21 October 2008 22:22 Go to previous messageGo to next message
Marcelo Alcantara is currently offline Marcelo AlcantaraFriend
Messages: 48
Registered: July 2009
Member
No hints about this issue?

Thanks again! :-)

"Marcelo Alcantara" <marcelo.alcantara@cshg.com.br> escreveu na mensagem
news:gdihj5$2de$1@build.eclipse.org...
> Hi,
>
> As there is a setDefaultButton in Shell/Decoration to handle ENTER on a
> shell, there is a way to handle a ESC press to the whole shell too? I
> could not find it anywhere.
>
> Thanks,
>
> Marcelo
>
Re: Handle ESC press to a whole shell as ENTER is handled with setDefaultButton [message #332475 is a reply to message #332463] Tue, 21 October 2008 23:11 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

AFAIK ESC can generate SWT.Traverse events. Added at the Shell level, a
TraverseListener could close the shell.

Is this what you are looking for?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Handle ESC press to a whole shell as ENTER is handled with setDefaultButton [message #332483 is a reply to message #332475] Wed, 22 October 2008 12:11 Go to previous messageGo to next message
Marcelo Alcantara is currently offline Marcelo AlcantaraFriend
Messages: 48
Registered: July 2009
Member
Hi Paul,

I solved the issue adding a filter to the display:

display.addFilter(SWT.KeyDown, new Listener()
{
public void handleEvent(Event e)
{
switch (e.keyCode)
{
case SWT.ESC:
{
Display.getCurrent().getActiveShell().close();
}
break;
}
}
});

Thanks for your help anyway.

Regads,

Marcelo

"Paul Webster" <pwebster@ca.ibm.com> escreveu na mensagem
news:gdlo16$kfp$2@build.eclipse.org...
> AFAIK ESC can generate SWT.Traverse events. Added at the Shell level, a
> TraverseListener could close the shell.
>
> Is this what you are looking for?
>
> PW
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: Handle ESC press to a whole shell as ENTER is handled with setDefaultButton [message #332484 is a reply to message #332483] Wed, 22 October 2008 12:48 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

On 10/22/2008 8:11 AM, Marcelo Alcantara wrote:
> Hi Paul,
>
> I solved the issue adding a filter to the display:

This is definitely a hack and I would strongly recommend you look at the
TraverseListener solution that Paul offered. Display filters apply to
all windows and widgets and thus this kind of listener is dangerous - if
you don't remove it it will probably result in undesired behavior after
your dialog is closed.


>
> display.addFilter(SWT.KeyDown, new Listener()
> {
> public void handleEvent(Event e)
> {
> switch (e.keyCode)
> {
> case SWT.ESC:
> {
> Display.getCurrent().getActiveShell().close();
> }
> break;
> }
> }
> });
>
> Thanks for your help anyway.
>
> Regads,
>
> Marcelo
>
> "Paul Webster"<pwebster@ca.ibm.com> escreveu na mensagem
> news:gdlo16$kfp$2@build.eclipse.org...
>> AFAIK ESC can generate SWT.Traverse events. Added at the Shell level, a
>> TraverseListener could close the shell.
>>
>> Is this what you are looking for?
>>
>> PW
>>
>> --
>> Paul Webster
>> http://wiki.eclipse.org/Platform_Command_Framework
>> http://wiki.eclipse.org/Command_Core_Expressions
>> http://wiki.eclipse.org/Menu_Contributions
>> http://wiki.eclipse.org/Menus_Extension_Mapping
>> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
>
>
Previous Topic:Updates and restoreState
Next Topic:myEditorPart#saveState(IMemento) not being called
Goto Forum:
  


Current Time: Thu Dec 26 23:50:28 GMT 2024

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

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

Back to the top