cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

XUI Window - Disable escape key press

TomLeoboldt
1-Newbie

XUI Window - Disable escape key press

Does anyone know how to temprarily disable the escape key while a XUI dialog is displaying? I have a XUI dialog that is launched from a Java/AOM class and I need to prevent the dialog from closing when the user presses the Esc key. The dialog includes both an OK and Cancel button and I need use of those to buttons to be the only way to close the dialog.


I'm pretty sure there must be some kind of event handler logic I could apply inside my controling Java/AOM app, but I do not know where to start on writing that logic. Any tips or assistance would be greatly appreciated.


I'm deploying this app on a UNIX/Solaris platform, though I do not know if that matters.


Regards,


Tom

6 REPLIES 6

The trick is that the escape button automatically triggers a 'click' event on the button in the dialog with type="cancel". So to disable the handling of the escape key, just put some condition in your cancel button handler that simply returns without dismissing the dialog in those cases.

Chris

Thank you. I believe I understand the explanation you provided below, but how do I detect that it was actually the Escape key that was pressed in the cancel event handler?

Here is a clip of my current cancel event handler:

EventListener cancelListener = new EventListener() {
public void handleEvent(Event event) {
event.stopPropagation();

// Dismiss the dialog
AbstractView view = ((UIEvent) event).getView();
Window win = ((View) view).getWindow();
win.close();
}
};

It is it just a line or two of code that needs to be added to recognize that the Escape key was pressed, or is it more than that? I do not have much of a background in window event handling, so if this is rather involved, please say so and I'll go study it for a bit in stead.

Regards,
Tom

Tom,

I'm not sure whether it's possible to tell that the original cause of the event was the escape key. However, presumably there's something going on in your application that makes dismissal of the dialog a bad idea, and in your cancel handler, you'd check that condition and if it was present, return without closing the dialog.

> EventListener cancelListener = new EventListener() {
> public void handleEvent(Event event) {
> event.stopPropagation();
if (!canClose()) return;
>
> // Dismiss the dialog
> AbstractView view = ((UIEvent) event).getView();
> Window win = ((View) view).getWindow();
> win.close();
> }
> };



Thank you, I get the idea now. This was a big help.

I can probably also put up an "Are you sure you want to cancel" dialog prompt if "!canClose()" is true to confirm whether the user actually intended to close the dialog window by trigger this event. (this is not a question ... just an observation)

Thanks again,
Tom

Tom,

Another option would be to disable the cancel button whenever the application enters a state where closing the dialog would be inappropriate. That way it will ignore any escape key presses as well as any direct clicks.

Chris

Does anybody know how to make "checkable" check boxes in PDF using Arbortext Editor 6.0 FOSI and Print Composer?

I can't seem to find anything about the subject in the Help. Maybe I'm searching for the wrong terms or something, but I doubt it.

I know it has to do with PDF forms and that you can edit an existing PDF file with Adobe Acrobat and do some forms creation and editing, but I want to do this programmatically so that the user does not have to edit the PDF file.

If FOSI and/or Print Composer is not a good method to do this and you know a different way, please advise on this as well.

Top Tags