Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Preventing Escape key on dialogs
Preventing Escape key on dialogs [message #466722] Mon, 16 January 2006 18:57 Go to next message
Hans is currently offline HansFriend
Messages: 36
Registered: July 2009
Member
I have a JFace dialog with a styled text field inside it, and when the
user hits Escape in this text field, the dialog should not close (on
Windows). I tried to add a VerifyKeyListener to the text field, but it
is not sufficient. Any ideas how I can block the Escape key here?

Hans
Re: Preventing Escape key on dialogs [message #466781 is a reply to message #466722] Tue, 17 January 2006 16:28 Go to previous messageGo to next message
Douglas Pollock is currently offline Douglas PollockFriend
Messages: 84
Registered: July 2009
Member
Hans wrote:
> I have a JFace dialog with a styled text field inside it, and when the
> user hits Escape in this text field, the dialog should not close (on
> Windows). I tried to add a VerifyKeyListener to the text field, but it
> is not sufficient. Any ideas how I can block the Escape key here?

From KeySequenceText:

switch (event.detail) {
case SWT.TRAVERSE_ESCAPE:
event.type = SWT.None;
event.doit = false;
break;


And this listener is hooked up using
Display.getCurrent().addFilter(SWT.Traverse, filter);

wenever the text field gets focus. I'm not sure that this is the best way
to do this, but it seems to work for us.



cheers,
d.
Re: Preventing Escape key on dialogs [message #466783 is a reply to message #466781] Tue, 17 January 2006 17:00 Go to previous messageGo to next message
Hans is currently offline HansFriend
Messages: 36
Registered: July 2009
Member
Excellent! I would have never found that out :)

Thanks
Hans

Douglas Pollock wrote:
> Hans wrote:
>
>>I have a JFace dialog with a styled text field inside it, and when the
>>user hits Escape in this text field, the dialog should not close (on
>>Windows). I tried to add a VerifyKeyListener to the text field, but it
>>is not sufficient. Any ideas how I can block the Escape key here?
>
>
> From KeySequenceText:
>
> switch (event.detail) {
> case SWT.TRAVERSE_ESCAPE:
> event.type = SWT.None;
> event.doit = false;
> break;
>
>
> And this listener is hooked up using
> Display.getCurrent().addFilter(SWT.Traverse, filter);
>
> wenever the text field gets focus. I'm not sure that this is the best way
> to do this, but it seems to work for us.
>
>
>
> cheers,
> d.
>
Re: Preventing Escape key on dialogs [message #466804 is a reply to message #466722] Tue, 17 January 2006 19:36 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
See
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet4.j ava

"Hans" <hans______@yahoo.com> wrote in message
news:dqgq9v$vu5$1@utils.eclipse.org...
> I have a JFace dialog with a styled text field inside it, and when the
> user hits Escape in this text field, the dialog should not close (on
> Windows). I tried to add a VerifyKeyListener to the text field, but it
> is not sufficient. Any ideas how I can block the Escape key here?
>
> Hans
Previous Topic:Intercepting keystrokes in SWT (StyledText)
Next Topic:bypassing default combo key reaction
Goto Forum:
  


Current Time: Wed Apr 24 23:17:16 GMT 2024

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

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

Back to the top