The Home Improvement stack by Brendan Bellina released on Script-Central v7n2 includes 20 ways to enhance the HyperCard IIGS Home stack.
One of these includes adding Function Key preference settings to the Home stack. This allows function keys F1-F4 to perform undo, cut, copy, paste, and F5-F15 to be user defined handlers or HyperTalk commands. These mappings can be defined regardless of whether a keyboard with function keys is attached to the IIGS or not.
Because the IIGS keyboard did not have function keys the ability of HyperCard IIGS to respond to function key presses is generally unused. If an Apple Extended Keyboard II is connected to the IIGS then its functions keys F1-F15 can be used and F1-F4 will perform undo, cut, copy, and paste, but without a stack or the Home stack having a functionkey handler the other function keys will serve no function.
When using a IIGS emulator it may not even be possible to send the function keys from the host computer keyboard through to the emulated IIGS, so the mappings preferences will also have no effect and even F1-F4 will not perform the built-in undo, cut, copy, and paste functions.
If you want to use the function key mappings preferences on a real IIGS that does not have an Apple Extended Keyboard II, or on an emulated IIGS with an emulator that eats the function key presses, then you have to have another way to indicate to HyperCard that a function key has been pressed.
Enter the Fn Key menu.
The Fn Key menu is a menu that can be added to HyperCard IIGS that can be used within any stack to send a function key signal to HyperCard as if a function key had been pressed.
Here are the steps to enable this menu.
1. Make a copy of your Home stack for safe keeping just in case you mess this up and need to revert.
2. You may want to follow the instructions in the Home Improvement stack to install the HC Extras menu. This menu adds significant functionality to HCGS and adds the addMenu and deleteMenu commands to the Home stack that are also required for the Fn Key menu.
3. If you choose not to use HC Extras then you will need to install the AddMenu XFCN and DeleteMenu XCMD from Apple's Scripter's Tools stack into your Home stack. Since you cannot install these into the active Home stack you will need to duplicate your Home stack, install them into the duplicate, and then rename or delete your original Home stack, and finally rename the duplicate to Home.
4. Make the following changes to your Home stack script:
4.1. In the startUp handler AND in the resume handler, after the line getHomeInfo add a new line
DrawHCFkeyMenu
If you have installed HCExtras then put the new line after the line
DrawHCExtrasMenu
4.2. In the quit handler AND in the suspend handler, after the line setHomeInfo add a new line
UnDrawHCFKeyMenu
4.3. Add the following two handlers: DrawHCFKeyMenu and UnDrawHCFKeyMenu
on DrawHCFKeyMenu -- FKey Menu by BTB 10/31/2022
global HCFKeyMenu
if HCFKeyMenu is not empty then
deleteMenu HCFKeyMenu
put empty into HCFKeyMenu
end if
put return into r
put empty into FKeyList
repeat with i = 1 to 15
put "F" & i after FKeyList
if i < 5 then put space & item i of "Undo,Cut,Copy,Paste" after FKeyList
put r after FKeyList
end repeat
put addMenu(" Fn Key ", FKeyList & "-" &r ¬
& "About the Fn Keys menu..." &r ¬
& "Refresh the Fn Keys menu...") ¬
into HCFKeyMenu
show menubar
end DrawHCFKeyMenu
on UnDrawHCFKeyMenu
global HCFKeyMenu
deleteMenu HCFKeyMenu
put empty into HCFKeyMenu
show menubar
end UnDrawHCFKeyMenu
4.4. Add the following code to your doMenu handler. Note that these should come before the final "else pass doMenu" in the handler. If there is no doMenu handler in your Home script then create one with "on doMenu whichItem" and "end doMenu"
else if whichItem is "About the Fn Keys menu..." then
answer " * * * FN KEYS M E N U ™ * * *" & return &¬
return & "Author: B. Bellina Vsn: 1.0" &¬
return & return &¬
"Send function keys without an extended keyboard"
else if whichItem is "Refresh the Fn Keys menu..." then
UnDrawHCFKeyMenu
DrawHCFKeyMenu
else if "*" & word 1 of whichItem & "*" is in ¬
"*F1*F2*F3*F4*F5*F6*F7*F8*F9*F10*F11*F12*F13*F14*F15*" then
delete char 1 of whichItem
functionKey (word 1 of whichItem)
5. After these changes then you restart HCGS you should see a new menu "Fn Keys" that you can use to send the F1-F15 keys to HyperCard IIGS.
No comments:
Post a Comment