OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: vladgothe on February 14, 2018, 03:57:55 PM

Title: OnCancelClose event
Post by: vladgothe on February 14, 2018, 03:57:55 PM
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.
Title: Re: OnCancelClose event
Post by: vladgothe on February 15, 2018, 04:46:50 AM
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.
Title: Re: OnCancelClose event
Post by: roy_043 on February 16, 2018, 03:39:56 AM
Maybe you can use:
(acet-sys-keystate 27)

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