OnCancelClose event

Started by vladgothe, February 14, 2018, 03:57:55 PM

Previous topic - Next topic

vladgothe

Hello,

I have a small problem and I don't know how to solve it. I want to prevent the user to close the form by pressing the ESCAPE key and at the same time I want to be able to close the form by pressing the "X" button from the titlebar. From what I understood, in OnCancelClose event, pressing the ESC key or clicking the X button is the same thing. One of my users was confused why the red "X" button wasn't working.

I have this code:

(defun c:MyForm#OnCancelClose (Reason /)
(/= isESCWasPressed 0)
)

This prevents the ESC key to close the form, but also prevents the X button to close the form. How can i activate the X button, while the ESC key is "disabled"?
Thanks in advance and sorry for my bad english.

vladgothe

I have an idea for this situation: when the user presses ESCAPE or X to hide the form (the form is modeless) and when the user presses ENTER to show the form.

roy_043

Maybe you can use:
(acet-sys-keystate 27)

Alternatively: remove the titlebar and create your own 'X' button.