Ron reminded me that Keyboard.RegisterHotkey also takes a filter parameter that lets you specify the window you want your registered hotkey to apply to. So if you have the editor window object, you could do:

Set myF8Key = Keyboard.RegisterHotkey("F8", "BeginSelect", theEditorWindow)
Set myShiftF8Key = Keyboard.RegisterHotkey("Shift-F8", "EndSelect", theEditorWindow)

Then those keys would only work in that specific window.

Aaron

Aaron Smith wrote:
Charles Steyn wrote:
Thanks very much for your comments. I'll experiment further. I'll have
to get the handling of the OnChildFocus and OnChildBlur events right
before my script really would work correctly.

It'd go something like this:

Dim theEditorWindow : Set theEditorWindow = <a window object representing the editor window>

ConnectEvent theEditorWindow, "OnChildFocus", "RegisterMyKeys"
ConnectEvent theEditorWindow, "OnChildBlur", "UnregisterMyKeys"

Sub RegisterMyKeys(windowObj)
    ' Register your keys here
End Sub

Sub UnregisterMyKeys(windowObj)
    ' Unregister your keys here
End Sub

How you find the editor window is up to you. In Studio 2008, the module name is MSENV, and the class name is VsTextEditPane. You could use the Window object's FilterByClassAndModule to search for that window, and if you find it, then hook your events (in that case, you'd use OnFocus and OnBlur rather than the child events because you are only interested in that one window). Alternatively, you could hook the main application window when the script starts, and then look for the right class name in your register/unregister subs. That would go a little something like this:

ConnectEvent ClientInformation.Overlap, "OnChildFocus", "RegisterMyKeys"
ConnectEvent ClientInformation.Overlap, "OnChildBlur", "UnregisterMyKeys"

Sub RegisterMyKeys(windowObj)
    If windowObj.ClassName = "VsTextEditPane" Then
        ' Register your keys here
    End If
End Sub

Sub UnregisterMyKeys(windowObj)
    If windowObj.ClassName = "VsTextEditPane" Then
        ' Unregister your keys here
    End If
End Sub

The second method is a bit more work, but it's another example of how to skin this cat.

Aaron


--
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.

Aaron Smith
GW Micro
Phone: 260/489-3671
Fax: 260/489-2608
WWW: http://www.gwmicro.com
FTP: ftp://ftp.gwmicro.com
Technical Support & Web Development

Reply via email to