Best Practices
Best Practices |
Overview of best practices when using the pen input panel object.
There are a few guidelines to keep in mind when using the PenInputPanel object.
Prefer InkEdit Control
InkEdit is the preferred control to which to attach the PenInputPanel object. The InkEdit control provides Text Services Framework (TSF) support.
Disable Ink Mode on InkEdit Controls
When attached to an InkEdit control, set the InkMode property of the InkEdit control to the InkMode.Disabled value. If the InkMode property is not set to the InkMode.Disabled value, the InkEdit control interprets the first tap as a stroke, passes it to the recognizer, and inserts the text in the InkEdit control. Since you already have a PenInputPanel object attached to accept ink input, there is no need to have the InkEdit control also enabled for ink input.
Using Windowless Controls
When a PenInputPanel object is attached to a parent window that contains more than one windowless control, the PenInputPanel object does not know how to track the caret as focus moves among windowless children. Handwriting input can be sent to the wrong child when focus moves from one windowless control to another while input is pending.
To use the PenInputPanel object in a windowless environment, the following technique can be used:
- Instantiate a TextBox control and position it over the windowless control.
- Attach the PenInputPanel object to the new text box control.
- Let the text box control collect the recognized text from the PenInputPanel object.
- When focus changes away from the text box control, call the CommitPendingInput method of the PenInputPanel object.
- Copy the recognized text from the text box control to the windowless child.
- Detach the PenInputPanel object by setting its AttachedEditControl property or AttachedEditWindow property to
null
. - Destroy the text box control.