Window Hook and Window Focus

I have coded a window hook to handle keyboard events. Thank you very much for the help here.

My Question:
I am using the keys to toggle checkboxes instead of forcing the user to click with the mouse and that is working fine.

However if a key that is not trapped for in my hook is pressed it gets passed to the command window and the focus is shifted.

What do I need to do to prevent this and ignore the errant keystrokes and keep the focus on the main window.
Whenever your hook functions returns 1, it signals that it handled the event. When it returns 0, it leaves the handling to Igor, which will, depending on the key pressed, switch to the command window.

I think you want to return 1 for all other keys.

One caveat here is that you might actually NOT want to do that for ALL keys. I haven't looked in the manual, but I imagine that catching certain "important" combinations might interfere with the normal/expected behavior of Igor.
The behavior you describe, in which typing causes activation of the command window, suggests that you are putting your controls into a graph. If instead you use a control panel, and make the graph a subwindow, you won't have that behavior.

I should also point out that on Windows checkboxes that have keyboard focus will respond to the Space bar. On Macintosh in Igor 7 this will also be true when you have Full Keyboard Access turned on.

On final note: if a control has focus (a SetVariable or Listbox may take keyboard focus, for instance) then the key press events go to the control and your window hook won't get them.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thank you for the replies.

I took the approach of just catching the keys around my designated shortcuts and passing them to the window hook with no function.

I found another alternative: Close the command window.

Andy