[Python-bugs-list] [ python-Bugs-768469 ] Alt key doesn't work in IDLE for MacOSX

SourceForge.net noreply@sourceforge.net
Fri, 11 Jul 2003 13:43:04 -0700


Bugs item #768469, was opened at 2003-07-09 08:49
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=768469&group_id=5470

Category: IDLE
Group: Python 2.3
Status: Open
Resolution: None
Priority: 7
Submitted By: Tiago Castro Henriques (tiagoh)
Assigned to: Kurt B. Kaiser (kbk)
Summary: Alt key doesn't work in IDLE for MacOSX

Initial Comment:
I'm running IDLE under MacOSX 10.2.6 using Python 2.3b2.

Using Apple's X11 beta 3 version, I am unable to access
any of the shortcuts that use the Alt key, including
the history keystrokes that recall past commands.

In my configuration at least, the Alt key is being used
(as usual) to access special characters and accented
characters.

Is there any way to bypass this, allowing the Alt key
to be handled directly by IDLE?

----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2003-07-11 15:43

Message:
Logged In: YES 
user_id=149084

Thank you for reporting the issues with help.txt and
extend.txt.  I will update these files. You are correct
about the renaming, extend.txt has not been updated
since the new config system was implemented.

I agree it would be nice to set the extension configuration
from the configuration dialog.  However, we are much too
close to release to contemplate doing that for 2.3.  

The extension feature is intended to incorporate 3rd party
features so the enhancement of the config dialog would
have to be suitably general.

Your problem appears to be down to one thing: none of
IDLE's "Classic Mac" Command combinations in your
config-keys.def work.  If I understand you correctly, you
are saying that e.g. replacing "Command-Key-w" by
"Meta-Key-w" in config-keys.def causes the
<<close-window>> event to work correctly?  

Note that Tk is very picky about capitalization.  
"Command-Key-w" is not the same as "Command-Key-W".  
Please be sure that your file is correct in this regard.  If
you can get everything working by doing this, would you
please upload the modified version of your config-keys.def
and let me know what the remaining problems are, if any.

In your messages you have variously said that both
"Command-B" and "Ctl-b" keystrokes go to the beginning
of a word.  Is this correct?  And do you really mean
"Apple/Shift/b" in the first case?

The Ctl-b binding and others like it that you have mentioned
in your earlier message are part of a number of default
Tk bindings that have not been disabled in IDLE.

http://www.tcl.tk/man/tcl8.3/TkCmd/text.htm#M141

Clearly, there may not be complete compatibility with this
documentation in the Tk Mac implementation.  But that is
the origin of the bindings.

By the way, the way to customize is not to modify 
config-keys.def, but to modify your .idlerc/config-keys.cfg
or any of the other files in that directory.

That is what the config dialog does, and it is quite all right
to modify it manually as long as you carefully follow the 
format.


----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-11 14:08

Message:
Logged In: YES 
user_id=819035

The file extend.txt references two files that do not exist:
keydefs and config.txt

I suppose the former corresponds config-keys.def, while the
latter has been split into 3 files: config-main.def,
config-extensions.def and config-highlight.def.

Is this correct?

Looking into config-extensions.def, I can finally see were
those non-standard key sequences are defined:

[FormatParagraph_cfgBindings]
format-paragraph=<Alt-Key-q>
(...)
[AutoExpand_cfgBindings]
expand-word=<Alt-Key-slash>
(...)
[ZoomHeight_cfgBindings]
zoom-height=<Alt-Key-2>
(...)
[ScriptBinding_cfgBindings]
run-module=<Key-F5>
check-module=<Alt-Key-x>

It would nice if these key bindings for extension modules
could be put in the same file as the standard key bindings.
Even nicer if the configuration dialog could be used to
change all key bindings.

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-11 13:48

Message:
Logged In: YES 
user_id=819035

Using the original [IDLE Classic Mac] shortcut keys
definitions, the only Command shortcuts that do anything are
the following:

Command-Q: tries to quit X11 instead of IDLE
Command-W: closes X11 windows instead of IDLE windows
Command-B: go to beginning of word
Command-F: go to end of word
Command-D: delete next word
Command-H: hide X11
Command-M: minimize window
Command-,: X11 preferences dialog

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-11 13:43

Message:
Logged In: YES 
user_id=819035

Sorry, my confusion. Since I edited my original
config-keys.def file, I forgot that the [IDLE Classic Mac]
shortcuts used the Command modifier, and not Alt. This
confusion is only made in my last message. If you replace
"Command" with "Alt" in that message, everything makes sense:

"""
If I change all keybinding using the Command-key in the [IDLE
Classic Mac] section of config-keys.def to use Meta instead
of Command, suddenly many of the shortcuts work using the
Command key (a.k.a Apple key).

However, it seems that those shortcuts that are already
being used by X11 take precedence:

Command-Q tries to quit X11 and not IDLE and Command-W
closes any X11 window, not just IDLE windows.

There is a simple workaround to this problem. For some
reason, if we use the Control-Command combination for Meta
instead of just the Command key, most shortcuts seem to work.
"""

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-07-11 13:22

Message:
Logged In: YES 
user_id=149084

First, I would like you to answer this question:

"What Alt keybindings are in the [IDLE Classic Mac]
section of your config-keys.def and how did they
get there, since there are none in the distributed
version of that file?"

Then, please read extend.txt and review the
config-extensions.def file.  The current implementation
of the configuration dialog does not have the ability
to customize the extension keybindings.

It may be possible to provide a special version of 
config-extensions.def for the Mac.  I will investigate.

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-11 11:32

Message:
Logged In: YES 
user_id=819035

With respect to problem 2, there is an easy workaround,
although it's not the ideal solution.

If I change all keybinding using the Alt-key in the [IDLE
Classic Mac] section of config-keys.def to use Meta instead
of Alt, suddenly many of the shortcuts work using the
Command key (a.k.a Apple key).

However, it seems that those shortcuts that are already
being used by X11 take precedence:

Command-Q tries to quit X11 and not IDLE and Command-W
closes any X11 window, not just IDLE windows.

There is a simple workaround to this problem. For some
reason, if we use the Control-Command combination for Meta
instead of just the Command key, most shortcuts seem to work.

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-11 11:22

Message:
Logged In: YES 
user_id=819035

With respect to question 3 in a previous message, some
keybindings seem to be hardcoded:

<<expand-word>> command, from AutoExpand.py:
Defined somewhere as <Alt-Key-/>.

<<zoom-height>> command, from ZoomHeight.py:
Defined as <Alt-Key-2> in TreeWidget.py.

<<format-paragraph>> command, from FormatParagraph.py:
Defined somewhere as <Alt-Key-q>.

<<check-module>> and <<run-module>> commands, from
ScriptBinding.py:
Defined somewhere as <Alt-Key-x> and <Key-F5>.

Several commands from files Bindings.py, EditorWindow.py and
PyShell.py do not have any key bindings:
<<about-idle>>, <<goto-file-line>>, <<help>>,
<<open-config-dialog>>, <<open-path-browser>>,
<<open-stack-viewer>>, <<toggle-debugger>>,
<<toggle-jit-stack-viewer>>, <<open-python-shell>>,
<<clear-breakpoint-here>> and <<set-breakpoint-here>>.

It would be cool to have keybindings for some of these, and
even cooler to be able to rebind them.

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-10 14:56

Message:
Logged In: YES 
user_id=819035

With respect to item 5) in my previous message
(user-friendly dialog boxes), the Tab key can be used to
cycle between buttons, which in conjunction with the Return
key improves keyboard usability a lot.

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-10 14:51

Message:
Logged In: YES 
user_id=819035

Keeping in mind Guido's goal of releasing Python2.3 by
August 1st (so that it can be included with MacOSX 10.3), we
should strive to make IDLE more Mac-friendly before that date:

In order to do this, we have to correct a few problems:

1) IDLE for MacOSX should use the [IDLE Classic Mac] keyset
by default.

Users should not be forced discover that the key-bindings
can be changed and then having to explicitly change the
configuration. We want to attract newbies to Python, and
IDLE should be the ideal tool for that.

2) The shortcut keys should work correctly.

Currently none of the key combinations that use the
Command-key work for me, which forces me to use the mouse
and the menus. The clipboard shortcuts (Com-C, Com-X, Com-V)
do not work, and other common shortcuts (Com-S, Com-N,
Com-O, Com-W) don't work either. Com-Q works, but it tries
to exit X11 altogether, instead of closing IDLE.

I know Mac users are used to using the mouse, but
power-users are also used to having the usual Command-key
shortcuts (e.g. Command-S to save a file).

I've tried most shortcuts, and the only ones that seem to
work for me are:
remove-selection=<Key-Escape>
smart-backspace=<Key-BackSpace>
newline-and-indent=<Key-Return> <Key-KP_Enter>
smart-indent=<Key-Tab>
beginning-of-line= <Key-Home>
end-of-file=<Control-Key-d> (same as Delete key)
history-next=<Control-Key-n>
history-previous=<Control-Key-p>
interrupt-execution=<Control-Key-c>
restart-shell=<Control-Key-F6>
comment-region=<Control-Key-3>
uncomment-region=<Control-Key-4>
tabify-region=<Control-Key-5>
untabify-region=<Control-Key-6>
toggle-auto-coloring=<Control-Key-slash>
toggle-tabs=<Control-Key-t>
change-indentwidth=<Control-Key-u>
find-again=<Command-Key-g> <Key-F3> (only the latter works)

Some shortcuts do not seem do to anything, although I might
be mistaken since I do not know exactly what they are meant
to do:
center-insert=<Control-Key-l>
view-restart=<Key-F6>
do-nothing=<Control-Key-F12>

The End key works correctly, although there is no
end-of-line entry in the config-keys.def corresponding to
it, as there is for the Home key (beginning-of-line=
<Key-Home>).

The usual Windows shortcuts work:
Ctl-Home, Ctl-End, Ctl-Up, Ctl-Down, Ctl-Left, Ctl-Right

Some common emacs bindings work as well (I only tested the
most basic bindings):
Ctl-p, Ctl-n, Ctl-b, Ctl-f, Ctl-a, Ctl-e

3) Eliminate incorrect shortcuts from menus.

Although none of the shortcuts listed in the [IDLE Classic
Mac] section of file
/usr/local/lib/python2.3/idlelib/config-keys.def uses the
Alt key, several menus show shortcuts that use that key (and
which do not work):
- In the Python Shell window:
Edit -> Expand Word (Alt-/)
Windows -> Zoom Height (Alt-2)
- In the Editor window:
Format -> Format Paragraph (Alt-Q)
Run -> Check Module (Alt-X)

There doesn't seem to be any entry in config-keys.def
corresponding to these shortcuts.

4) The "IDLE Help" window should be updated.

Currently, it lists a few shortcuts that do not work in
MacOSX. Quoting:
"""
Command history:

	Alt-p retrieves previous command matching what you have typed
	Alt-n retrieves next
	Return while on any previous command retrieves that command
	Alt-/ (Expand word) is also useful here
"""


A help document that gives incorrect information is worse
than having no information.

5) Dialog Boxes should be keyboard friendly.

Presently I cannot use the keyboard to choose Dialog Box
buttons (Yes or No buttons, for instance). The only keys
that seem to work are Escape and Return.


6) Menus should be keyboard friendly.

The Alt-Underlined_Letter method that is used to navigate
menus in the Windows world doesn't seem to work with IDLE in
MacOSX.

Although this doesn't seem to be documented, F10 can be used
to open the first menu item, which enables us to operate
menus with the keyboard although this is not as efficient as
direct menu access.

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-07-10 11:42

Message:
Logged In: YES 
user_id=149084

The "Classic Mac" keyset uses Control-Key-n for
history-next and Control-Key-p for history-previous.

The Alt key isn't used in this keyset.  
(The keyset is defined in config-keys.def)

Are you saying that when "Classic Mac" is set that
Alt key accelerators are appearing in the menus?

----------------------------------------------------------------------

Comment By: Tiago Castro Henriques (tiagoh)
Date: 2003-07-10 08:52

Message:
Logged In: YES 
user_id=819035

I've tried all three of the Built-in key sets, and the
problem remains. I tried restarting idle to see if that was
the problem, but I still have the same problem. Maybe there
is something I'm missing, but it doesn't seem obvious to me
how to make it work.

Unless I'm doing something stupid, this would be a serious
defect with respect to IDLE usability under MacOSX

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-07-10 00:25

Message:
Logged In: YES 
user_id=149084

It sounds to me like you don't have the Mac bindings
enabled.  Try 
Options / Configure IDLE / Keys
and select the IDLE Classic Mac Key Set

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=768469&group_id=5470