Discussion:
esc key to close a window
Carlo
2009-04-03 12:57:35 UTC
Permalink
A few days ago somebody (Sven, as far as I remember), mentioned the
use of esc key to close a window.

I have to confess that I had never heard of it, so I would like to
know if on the Mac this has really become a standard/expected feature.

And if that is the case, will the following code be OK in the keydown
event of a window?
if key = chr(27) then
self.close
Return true
end if

Thanks,


Carlo




_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Jean-Luc Arnaud
2009-04-03 13:31:12 UTC
Permalink
Post by Carlo
A few days ago somebody (Sven, as far as I remember), mentioned the
use of esc key to close a window.
I have to confess that I had never heard of it, so I would like to
know if on the Mac this has really become a standard/expected
feature.
And if that is the case, will the following code be OK in the
keydown event of a window?
if key = chr(27) then
self.close
Return true
end if
Thanks,
Carlo
Esc key is not a standard Mac shortcut to close a window.

It's used to be Cmd-w (Cmd stands for Command, the Apple key).

HTH

Jean-Luc

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Sven E Olsson
2009-04-03 14:10:52 UTC
Permalink
1 - Check some Apple Applications About Window ( is closed with Esc )
2 - Check Apple Mail Address Panel ( is closed with Esc )
3 - Check Apple TextEdit Find Panel ( is closed with Esc )
4 - Check Apple iCaht, Add Buddy ( drawer is closed by Esc )
5 - Check TextWrangler Find Window ( is closed with Esc )
6 - Check iCal Availability Window ( is closed with Esc )
7 - Check TextMate Show Web View ( is closed with Esc )
8 - Check Komodo Find Window ( is closed with Esc )
9 - Check Apple Icon Composer About Window ( is closed with Esc )
10 - Check SEEdit Maxi II CSS Classes Window ( is closed with Esc )

Note: It looks like "Main Window" and Preferences Window is NOT closed
by Esc, but then generate a beep.

Sven E
Post by Jean-Luc Arnaud
Esc key is not a standard Mac shortcut to close a window.
It's used to be Cmd-w (Cmd stands for Command, the Apple key).
HTH
Jean-Luc
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2009-04-03 15:01:52 UTC
Permalink
Generally, Esc means that something is being cancelled. This seems a
reasonable interpretation for the window examples you collected.

Charles Yeomans
Post by Sven E Olsson
1 - Check some Apple Applications About Window ( is closed with Esc )
2 - Check Apple Mail Address Panel ( is closed with Esc )
3 - Check Apple TextEdit Find Panel ( is closed with Esc )
4 - Check Apple iCaht, Add Buddy ( drawer is closed by Esc )
5 - Check TextWrangler Find Window ( is closed with Esc )
6 - Check iCal Availability Window ( is closed with Esc )
7 - Check TextMate Show Web View ( is closed with Esc )
8 - Check Komodo Find Window ( is closed with Esc )
9 - Check Apple Icon Composer About Window ( is closed with Esc )
10 - Check SEEdit Maxi II CSS Classes Window ( is closed with Esc )
Note: It looks like "Main Window" and Preferences Window is NOT
closed by Esc, but then generate a beep.
Sven E
Post by Jean-Luc Arnaud
Esc key is not a standard Mac shortcut to close a window.
It's used to be Cmd-w (Cmd stands for Command, the Apple key).
HTH
Jean-Luc
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Bart Silverstrim
2009-04-03 15:12:34 UTC
Permalink
Post by Charles Yeomans
Generally, Esc means that something is being cancelled. This seems a
reasonable interpretation for the window examples you collected.
See, I like using "E". It gives the users that thrill of discovering an
easter egg in the program.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Jean-Luc Arnaud
2009-04-03 15:11:16 UTC
Permalink
Post by Sven E Olsson
1 - Check some Apple Applications About Window ( is closed with Esc )
2 - Check Apple Mail Address Panel ( is closed with Esc )
3 - Check Apple TextEdit Find Panel ( is closed with Esc )
4 - Check Apple iCaht, Add Buddy ( drawer is closed by Esc )
5 - Check TextWrangler Find Window ( is closed with Esc )
6 - Check iCal Availability Window ( is closed with Esc )
7 - Check TextMate Show Web View ( is closed with Esc )
8 - Check Komodo Find Window ( is closed with Esc )
9 - Check Apple Icon Composer About Window ( is closed with Esc )
10 - Check SEEdit Maxi II CSS Classes Window ( is closed with Esc )
Note: It looks like "Main Window" and Preferences Window is NOT
closed by Esc, but then generate a beep.
Sven E
Post by Jean-Luc Arnaud
Esc key is not a standard Mac shortcut to close a window.
It's used to be Cmd-w (Cmd stands for Command, the Apple key).
HTH
Jean-Luc
Sure, but main of these windows are Dialogs, and Esc is equal to
'Cancel', not 'Close'.

'Close' is Cmd-w.

Jean-Luc

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Sven E Olsson
2009-04-03 17:38:02 UTC
Permalink
Post by Jean-Luc Arnaud
Sure, but main of these windows are Dialogs, and Esc is equal to
'Cancel', not 'Close'.
'Close' is Cmd-w.
Jean-Luc
I am not sure at that, Cancel do it not mean: "Go back" and "Don't
change or Save anything" ?

Sven E


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Jean-Luc Arnaud
2009-04-03 13:42:17 UTC
Permalink
Post by Carlo
A few days ago somebody (Sven, as far as I remember), mentioned the
use of esc key to close a window.
I have to confess that I had never heard of it, so I would like to
know if on the Mac this has really become a standard/expected
feature.
And if that is the case, will the following code be OK in the
keydown event of a window?
if key = chr(27) then
self.close
Return true
end if
Thanks,
Carlo
Some additional info :

Esc is KB shortcut for Cancel answer in dialogs, like :

Do you want to close the window ?

Yes (-> Return or Enter) No (-> Esc)


Or like this :

Do you want to save before quiting ?

Yes (-> Return, Enter) No Cancel (-> Esc)


Jean-Luc

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Joe Strout
2009-04-03 13:52:56 UTC
Permalink
A few days ago somebody (Sven, as far as I remember), mentioned the use
of esc key to close a window.
I have to confess that I had never heard of it, so I would like to know
if on the Mac this has really become a standard/expected feature.
I'm not sure how standard it is, but if you have a modal dialog
(especially one with either a Cancel button or no buttons at all), it's
something that some users are likely to try. And friendly apps will
anticipate anything users might try, and make them do what the users
would want as much as possible.

So, by that principle, interpreting the Esc key to mean "close the
window" is probably much better than simply ignoring it.
And if that is the case, will the following code be OK in the keydown
event of a window?
if key = chr(27) then
self.close
Return true
end if
Yup, though "self." isn't actually needed here.

Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
ER
2009-04-03 17:24:23 UTC
Permalink
Post by Joe Strout
I'm not sure how standard it is, but if you have a modal dialog
(especially one with either a Cancel button or no buttons at all),
it's something that some users are likely to try. And friendly apps
will anticipate anything users might try, and make them do what the
users would want as much as possible.
So, by that principle, interpreting the Esc key to mean "close the
window" is probably much better than simply ignoring it.
I agree.

I don't see a problem with using the Esc key to close a window. I
haven't done it, yet..., but not really a big deal.
Just state in the "Read Me's" or whatever that esc will close a
window. Either the users will have no problem with,
get use to it/get over it, or won't use it.

Besides, where to "think different" right ? ;-)



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Tim Jones
2009-04-03 15:09:10 UTC
Permalink
Post by Carlo
A few days ago somebody (Sven, as far as I remember), mentioned the
use of esc key to close a window.
I have to confess that I had never heard of it, so I would like to
know if on the Mac this has really become a standard/expected feature.
And if that is the case, will the following code be OK in the
keydown event of a window?
if key = chr(27) then
self.close
Return true
end if
Here's the code I use so that both the Command-W and Esc work in my
about dialogs:

if Uppercase(key) = "W" then
// Check to see if the Cmd key is also down
if Keyboard.AsyncCommandKey = True Then
WAbout.Close
End If
ElseIf Asc(Key) = 27 Then
WAbout.Close
End If

Tim


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Bryan Dunphy
2009-04-03 15:40:07 UTC
Permalink
Post by Tim Jones
Here's the code I use so that both the Command-W and Esc work in my
if Uppercase(key) = "W" then
// Check to see if the Cmd key is also down
if Keyboard.AsyncCommandKey = True Then
WAbout.Close
End If
ElseIf Asc(Key) = 27 Then
WAbout.Close
End If
Tim
Wouldn't this code do the same thing more easily:

If (UpperCase(key) = "W" And Keyboard.ASyncCommandKey) Or Asc(Key) =
27 Then WAbout.Close

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Joe Strout
2009-04-03 15:53:01 UTC
Permalink
If (UpperCase(key) = "W" And Keyboard.ASyncCommandKey) Or Asc(Key) = 27
Then WAbout.Close
Yes, but I'd go even further:

1. There's no need for UpperCase here; RB string comparisons are
case-insensitive.

2. Checking AsyncCommandKey is technically not correct; it should be
just CommandKey (you want to know if it was down when the key event was
generated, not whether it's down at the moment).

3. Even better (much, IMHO) would be to have a Close menu handler, where
Close of course has a cmd-W shortcut. It's really none of your
program's business that the user is pressing Command and the W key to
invoke this menu command; they should be able to accomplish the same
thing using the mouse, or using Speakable UI, or any of several other
ways I'm probably forgetting.

Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Tim Jones
2009-04-03 16:02:17 UTC
Permalink
Post by Joe Strout
Post by Bryan Dunphy
If (UpperCase(key) = "W" And Keyboard.ASyncCommandKey) Or Asc(Key)
= 27 Then WAbout.Close
1. There's no need for UpperCase here; RB string comparisons are
case-insensitive.
Old habit...
Post by Joe Strout
2. Checking AsyncCommandKey is technically not correct; it should
be just CommandKey (you want to know if it was down when the key
event was generated, not whether it's down at the moment).
But, Apple's UI Guideline group actually suggested the opposite in
that the user may change their mind in the middle of the operation.
Post by Joe Strout
3. Even better (much, IMHO) would be to have a Close menu handler,
where Close of course has a cmd-W shortcut. It's really none of
your program's business that the user is pressing Command and the W
key to invoke this menu command; they should be able to accomplish
the same thing using the mouse, or using Speakable UI, or any of
several other ways I'm probably forgetting.
But, quite often an about dialog is not tied to a Menu and has no
menu events defined. Having the option in both places is not
harmful, but it allows for non-menu-assigned windows to also respond
to the Command-W.

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Tim Jones
2009-04-03 15:58:55 UTC
Permalink
Post by Bryan Dunphy
Post by Tim Jones
Here's the code I use so that both the Command-W and Esc work in
if Uppercase(key) = "W" then
// Check to see if the Cmd key is also down
if Keyboard.AsyncCommandKey = True Then
WAbout.Close
End If
ElseIf Asc(Key) = 27 Then
WAbout.Close
End If
Tim
If (UpperCase(key) = "W" And Keyboard.ASyncCommandKey) Or Asc(Key)
= 27 Then WAbout.Close
More easily, no, less code, yes, but I was trying to let the code
example be easy to understand. And, I don't do single line If ...
Then statements as a matter of coding style consistency.

Tim


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Carlo
2009-04-03 15:56:27 UTC
Permalink
Thanks to all who answered!


Carlo




_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Loading...