Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there any way to securely stick a notebook window (e.g. a dialog) on screen that it cannot be closed/removed/hidden by any of the standard OS shortcuts, like AltF4 or AltTab under Windows? The ideal solution would allow me to specify a range of key-combinations that can be used, and block any other, though it would not be a problem to block all keyboard input, as there are other ways to close a modal dialog.

I have a feeling that this cannot be done entirely from under Mathematica, though I'll give it a go. You can experiment with the following example:

CreateDialog[{TextCell["Click OK to close"], DefaultButton[]}, Modal -> True]

Purpose: I'm doing some experimentation on humans in Mathematica, and since this species is known by its extensive explorative behaviour (i.e. pushing all buttons) and the ability to ruin everything, I want to make the experiment-gui foolproof so that they can't remove it from the screen. This is a must, as it could happen that they hit AltF4 (accidentally or intentionally) and quit at the middle of a test, rendering any saved data useless.

share|improve this question
    
I guess you figured out that WindowFrameElements -> {} doesn't prevent Alt-F4 from working. –  Szabolcs Apr 19 '12 at 15:14
    
Not sure this is a Mathematica-specific question? Maybe people over on SuperUser might have ideas that can then be implemented in MMA? –  Eli Lansey Apr 19 '12 at 15:22
    
@Szabolcs Setting WindowFrameElements -> {} does prevent Cmd-w from closing the notebook on OS X. –  Heike Apr 19 '12 at 15:34
    
I now how to do it in AutoHotKey, though I would prefer a domestic solution. –  István Zachar Apr 19 '12 at 15:36
    
@Heike that doesn't help for Alt-F4 –  Eli Lansey Apr 19 '12 at 15:41
show 9 more comments

1 Answer 1

Not 100% solution, but this may work. Define:

dialog := 
 CreateDialog[{TextCell["Click OK to close"], DefaultButton[]}, 
  Modal -> True, NotebookEventActions -> {"WindowClose" :> dialog}]

Then call:

dialog

At least, it reappears :)

share|improve this answer
1  
Devilish workaround :) But unfortunately it does not prevent accidental Alt+Tab changes and similar non-invasive key combinations which simply just hide the window. –  István Zachar Apr 19 '12 at 20:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.