I have embedded Acrobat Reader in my WPF application, and I have defined several hotkeys that I want to do some work, but the hotk开发者_如何学JAVAeys only work when I'm inside textboxes and similar. I have discovered that this must be because Adobe Acrobat Reader gets the hotkeys before I do, because if I map ctrl-shift-s to a function, when I press it inside a textbox my function is called, but if the focus is not in a textbox, Adobe's save function is called.
How can I make sure my the hotkeys defined for MainWindow are the ones that are executed, and not that of Acrobat Reader or anything else?
Cheers
Nik
That sounds like keyboard focus in your application defaults to the embedded Acrobat Reader, so when your main window gets a key press it gives them to Reader in preference of anything else, including its own menu commands.
That's somewhat difficult since you likely want Reader to receive focus and handle its keyboard shortcuts -- just not the ones that are also defined by your main window.
Try overriding OnKeyDown in your MainWindow class and see if Ctrl+Shift+S arrives there. If it does, respond by directly calling your appropriate command event handler, and set Handled to true on the event argument to prevent MainWindow from sending that key anywhere else.
精彩评论