Definehotkeys' "window" scope

There’s no example given in help of using the window scope, and I can’t find anything in the course material.

You define a hot key for a window by quoting the window name in the scope parameter. Can you define the same hot key and code for multiple windows in the one definehotkeys statement by putting all their names in the scope parameter, and if so what’s the syntax?

Or would you have to repeat the whole definehotkeys statement with each different window name?

David Duncan

If you define a hotkey for window scope, that is for the current window. If you want to define a hotkey for some other window, you would first have to switch to that window. Usually if you wanted to define a hotkey for a particular window, you would do that right after the openform statement that opens the window, or if for a dialog, in the initialization code for that dialog.

The same rules apply for database scope – that is for the current database. In most cases you would probably set those up in the .Initialize procedure.

If one or more hotkeys are defined for a particular scope, those hotkeys go away when the scope goes away. So if you’ve defined hotkeys with window scope, those hotkeys will vanish when the window is closed, while database scope hotkeys will vanish when the database closes. Hotkeys aren’t permanent (there may be an option for permanent database hotkeys in the future).

Thanks for that, I get it now. Will you add that to the definehotkeys help page, or would you like me to have a shot at it?

I’m open to suggestions. The word scope is actually a term commonly used by programmers, so I suspect any experienced programmer would already know what is going on. Perhaps it could be explained better for non-programmers, but I’m not sure if this topic is the top priority for further explanation for non-programmers. BTW, the word scope is used in other places in exactly the same way, for example in the starttimer statement. Maybe the best solution would be a new page specifically for this term.

If you define a hotkey for window scope, that is for the current window, so you would do that right after the openform statement that opens the window, and if for a dialog, in the initialization code for that dialog. When the window or dialog is closed, the hot key goes away.

This extract from your post would have told me all I needed to know, and if it was added to the help page I think it would be of assistance to non-programmers like me.