Disable cancel in a Dialog?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Disable cancel in a Dialog?

Christopher J. Demers
Is there any way to disable cancel in a dialog?  I have tried using
queryCommand: but to no avail.  I even tried overriding cancel, but one can
still cancel with the escape key.  It seems that there is no (easy) way to
prevent a user from canceling a dialog.  Any ideas?

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Disable cancel in a Dialog?

Louis Sumberg-2
Chris,

One way might be to subclass Dialog, override cancel (to do nothing).  That
seems to take care of the cancel button and escape key.  You'd also have to
set hasSysMenu to false so the user can't close it that way.  It seems to
work though I wouldn't say it's pretty.

> Is there any way to disable cancel in a dialog?  I have tried using
> queryCommand: but to no avail.  I even tried overriding cancel, but one
can
> still cancel with the escape key.  It seems that there is no (easy) way to
> prevent a user from canceling a dialog.  Any ideas?

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: Disable cancel in a Dialog?

Christopher J. Demers
Louis Sumberg <[hidden email]> wrote in message
news:9ttfnu$ljt$[hidden email]...
> One way might be to subclass Dialog, override cancel (to do nothing).
That
> seems to take care of the cancel button and escape key.  You'd also have
to
> set hasSysMenu to false so the user can't close it that way.  It seems to
> work though I wouldn't say it's pretty.

Thanks for the response.  Interesting, that did not seem to work for me on
Windows 2000.  Overriding the cancel method would prevent the cancel button
from working, but the escape key would still cancel. It was very late, and
maybe my mind was not working.

Anyhow for posterity sake I found out how to do it in queryCommand: which
seems more proper anyway.  I looked at ProgressDialog<<queryCommand: for an
example.  This bit of code and comment seem to explain it, it needed
something special :

  "Note that we need to force ourselves as the command target to disable
cancel"
  query isEnabled: self allowCancel; receiver: self.

Once I did that in my dialog it worked as I wanted it to.

Chris