Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Preventing Escape key on dialogs
Preventing Escape key on dialogs [message #466722] Mon, 16 January 2006 13:57 Go to next message
Eclipse UserFriend
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 11:28 Go to previous messageGo to next message
Eclipse UserFriend
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 12:00 Go to previous messageGo to next message
Eclipse UserFriend
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 14:36 Go to previous message
Eclipse UserFriend
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 Jul 09 22:19:04 EDT 2025

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

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

Back to the top