In a fit of enthusiasm, I decided to add some accelerator keys to an existing program. Some hours later, I find myself completely bemused.
When setting up the menu system, I finally puzzled out how it works, and managed to do wonderful things with (for example) PgUp and PgDn.
In common with many other programs, I associated Ctrl+N with File|New, Ctrl+O with File|Open, and Ctrl+S with File|Save. It appears to me that although these sequences are listed in the relevant menus, they don't work. I imagine that Ctrl+ any letter doesn't.
So, Question 1: Am I right that Ctrl+ a letter (like Ctrl+N) only works with %ac, and not with %mn?
In my simplicity, I had assumed that it would, and so when the menu was greyed-out, the accelerator would be disabled too. I think that the answer to Q1 is Yes, and greying-out the menu doesn't disable the accelerator.
It didn't seem so bad, as maybe that is what the %ac format is there for. Hooray! It is. Ctrl+ a letter sequences work as expected. I already knew that there were subroutines ADD_ACCELERATOR@ and REMOVE_ACCELERATOR@. A quick check revealed that they weren't FUNCTIONs (a trap I sometimes fall into) - and that I have INCLUDEd WINDOWS.INS.
CALL REMOVE_ACCELERATOR@ (MASTER(1), 'Ctrl+N')
CALL REMOVE_ACCELERATOR@ (MASTER(1), 'Ctrl+O')
MASTER(1) is the handle of my main window.
When it didn't remove the accelerator, I had a quick go with square brackets '[Ctrl+N]', but that's definitely wrong as FTN95 complains.
Question 2: Is it the case that you can only remove an accelerator that is associated with ADD_ACCELERATOR@ ?
If the answer to question 2 is Yes, then clearly the accelerators you need to turn on and off can go in the callback for %sc. However, as ADD_ACCELERATOR@ can't use standard callbacks such as FILE_OPENR this route does have a certain amount of additional coding associated with it that I have yet to attempt.
I found a note that said accelerators should not go in top level menus. This leads to Question 3: Why not? They seem to work (but only if they are of the form Alt+F4 for Exit and F1 for Help) and other programs use this approach.
I'm using 4.9.0
Eddie
PS it looks like you can add and remove only accelerators added and removed via the suboutine calls.