[comp.sys.mac.programmer] changing the keyboard layout in System 7

bruner@sp15.csrd.uiuc.edu (John Bruner) (05/30/91)

I'm trying to change the keyboard layout while one of my programs is
running.   According to technical note 160, I can do this by putting
appropriate KCHR and SICN resources in my application's resource fork
and calling the Script Manager routines SetScript and KeyScript.

Alas, although it worked for me with System 6.0.7, this doesn't seem
to work with System 7.  By trial and error I've discovered that I must
put the KCHR resource into the System file.  Is this true -- the
technote is obsolete and the KCHR must be in the System file -- or am
I missing something?  (I'll put it in the System file if necessary, but
I'd rather not.)
--
John Bruner	Center for Supercomputing R&D, University of Illinois
	bruner@csrd.uiuc.edu		(217) 244-4476

ftanaka@Apple.COM (Forrest Tanaka) (05/30/91)

bruner@sp15.csrd.uiuc.edu (John Bruner) writes:

>I'm trying to change the keyboard layout while one of my programs is
>running.   According to technical note 160, I can do this by putting
>appropriate KCHR and SICN resources in my application's resource fork
>and calling the Script Manager routines SetScript and KeyScript.
>
>Alas, although it worked for me with System 6.0.7, this doesn't seem
>to work with System 7.  By trial and error I've discovered that I must
>put the KCHR resource into the System file.  Is this true -- the
>technote is obsolete and the KCHR must be in the System file -- or am
>I missing something?  (I'll put it in the System file if necessary, but
>I'd rather not.)

You're not missing anything.  Beginning with system software version 7.0, KCHR
resources must be in the System file to be loaded by an application.  This
was done to prevent problems with applications which load their own KCHR and
then unexpectedly quit, leaving the system pointing at a KCHR that doesn't
exist any more.  There might be other reasons, but that's the one that I know.

Now that KCHRs can be in Keyboard Layout files, users can just drag them into
their System file.  Applications which have their own KCHR should provide
that KCHR in a Keyboard Layout file and then tell users to drag that file
over to the blessed folder.  Programmers who want their application to run
under both 7.0 and pre-7.0 systems can still provide the same KCHR in the
application's resource fork so that the KCHR can be loaded from there on
pre-7.0 systems.

Personally, I'd have preferred engineering left things as they were because
there are applications which absolutely have to load KCHRs from their own
resource fork, and now they're broken to a certain degree.  I've been talking
to engineering about interim solutions for those applications until a good
solution is in place, like maybe application-specific KCHR caches or something.
Hopefully, we'll be able to have a makeshift solution available sometime in the
summer.  Even more hopefully, we'll have a real solution in some future system.

You're right; Tech Note #160 is out of date because of this change.  I'll
update it as soon as I can.

-- Forrest

>John Bruner	Center for Supercomputing R&D, University of Illinois
>	bruner@csrd.uiuc.edu		(217) 244-4476


-- 
Forrest Tanaka                                     "If Isaac Newton is resting,
Internet: ftanaka@apple.com                         he wants to keep resting."
Speaking on behalf of myself              -- Click & Clack, the tappet brothers

kiran@copper.ucs.indiana.edu (Kiran Wagle) (05/30/91)

bruner@sp15.csrd.uiuc.edu (John Bruner) writes:

>I'm trying to change the keyboard layout while one of my programs is
>running.   According to technical note 160, I can do this by putting
>appropriate KCHR and SICN resources in my application's resource fork
>and calling the Script Manager routines SetScript and KeyScript.

>Alas, although it worked for me with System 6.0.7, this doesn't seem
>to work with System 7.  By trial and error I've discovered that I must
>put the KCHR resource into the System file.  Is this true -- the
>technote is obsolete and the KCHR must be in the System file -- or am
>I missing something?  (I'll put it in the System file if necessary, but
>I'd rather not.)

So it isn't just me having trouble with this....

  I had to remap the keys in my system keyboard when i upgraded to 7.0 
ZTerm has two 'kchr's in it, which i suppose i was using with 6.0.7,
but i needed to remap a key under 7.0 (^@, the emacs mark-setting key)
Why? Is this a 'feature'?

Does the new system want to prevent people from 
	dragging a keyboard into the system file...
	finding it doesn't work in an app with it's own 'kchr'...
	and complaining "$#@&* buggy 7.0 won't use my new keyboard!"
even though using the app's resources first is not a bug? 

Or is this an obscure 7.0 bug? If so, i'll claim it--
I found it on May 15 when i tried to check my mail after installing 7.0!
--
	...kiran
		__________kiran@copper.ucs.indiana.edu________(812) 331-1710

From the corrections column in a July Fresno, CA _Bee_:
"An item in Thursday's [issue] about the Massachusetts budget crisis
made reference to new taxes that will help put Massachusetts 'back in
the African-American.' The item should have said 'back in the black.'"