locked
Keyboard Info in ITextView RRS feed

  • Question

  • I've started a simple extension based off of the sample template that draws boxes around a's. (I'm doing something different of course)

     

    The problem I'm having is I don't know how to get keyboard input. Basically I need to make a decision based on what key was pressed(basically del, tab, and enter). Is there any way when working with ITextView to get the last key used that triggered the OnLayoutChanged event?

    Friday, April 22, 2011 1:37 AM

Answers

  • Actually even subclassing won't work as we don't forward the WM_KEYDOWN if it maps to a command.  I imagine the best you could do would be to insert yourself into the editors command filter chain and watch the commands as they go by, I believe 'normal' typing will flow as TYPECHAR commands, other things like del, enter will flow as the mapped commands within the editor scope.

    Ryan

    Monday, April 25, 2011 4:58 PM

All replies

  • Hello JonSlaughter,

     

    Thank you for your question.

     

    I am currently looking into this issue and will give you an update as soon as possible.

     

    Thank you for your understanding and support.

     

    Best Regards,

    Ziwei Chen

     

     

     

     


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 25, 2011 8:55 AM
  • Thanks.

     

    Right now I am checking the difference between the old and new snapshots to guess at what happened. For example, if a '\t' is the only difference at the caret then I assume it's a tab. It would be much more efficient and less error prone if I could just check and see what keystroke happened and deal with more complex keystrokes(backspace, del, etc) that might have occurred.

    Monday, April 25, 2011 12:30 PM
  • I don't think this will be possible. Keystrokes in the editor are generally turned into commands and thus aren't propagated as "regular" keyboard input. You could try something like subclassing the main window's HWND, but that would of course be unsupported.

    Ryan

    Monday, April 25, 2011 3:46 PM
  • Actually even subclassing won't work as we don't forward the WM_KEYDOWN if it maps to a command.  I imagine the best you could do would be to insert yourself into the editors command filter chain and watch the commands as they go by, I believe 'normal' typing will flow as TYPECHAR commands, other things like del, enter will flow as the mapped commands within the editor scope.

    Ryan

    Monday, April 25, 2011 4:58 PM