Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Setting Context for Ink-Enabled Controls |
Describes special considerations for setting context on ink-enabled controls.
All recognition for ink-enabled controls occurs through a RecognizerContext object. The Microsoft® Windows® XP Tablet PC Edition Platform APIs allow you to set the Factoid property on a RecognizerContext object.
If you are creating an ink-enabled application, use the RecognizerContext object's Factoid and WordList properties to set contexts.
You may pass in the string values of the names in the input scopes defined in the InputScope enumeration to the Factoid property, delimited with an opening (! and a closing ). For example, to set the context for a RecognizerContext object to bias toward characters used in a URL, use the syntax shown in the following C# examples:
theRecoContext.Factoid = "(!IS_URL)";
Note: The input scopes as defined in the InputScope enumeration supersede the factoids that were available in previous versions of the Windows XP Tablet PC Edition Software Development Kit (SDK), although these factoids will continue to work in order to provide backward compatibility.
The following C# example sets the Factoid property for postal codes:
theRecognizerContext.Factoid = "(!IS_ADDRESS_POSTALCODE)";
You may combine input scopes by using the handwriting regular expression syntax. For more details about using regular expression syntax, see Custom Input Scopes with Regular Expression.
You may set recognition flags on the RecognizerContext object to affect the behavior of the recognizer. One such flag is the Coerce flag. The Coerce flag forces the recognizer to return a result that matches the definition of the factoid that is set. For example, if you have a form that requires the user to enter a numerical quantity, it may be useful to set the IS_NUMBER factoid and also set the RecognitionFlags property to Coerce. In that instance, the Coerce flag guarantees that the recognizer returns only numbers.
The following C# example sets the RecognitionFlags property to Coerce:
theRecognizerContext.RecognitionFlags = RecognitionModes.Coerce;
However, use caution when deciding to set the Coerce flag. The flag forces the recognizer to match only the definition of the factoid. For example, if you set the IS_TELEPHONE_FULLTELEPHONENUMBER input scope and the Coerce flag, the recognizer returns results that exactly match the definition of the IS_TELEPHONE_FULLTELEPHONENUMBER input scope only. If a user writes "911" with the IS_TELEPHONE_FULLTELEPHONENUMBER input scope and the Coerce flag set, the recognizer may return either an empty string or a random string in the format of (XXX) XXX-XXXX (where X is a digit). The format of XXX does not match the definition of the IS_TELEPHONE_FULLTELEPHONENUMBER factoid, even though it is a valid phone number.
For lists of the supported formats for each input scope, see the InputScope enumeration reference.
To return a field to the default setting for the recognizer, set the factoid to IS_DEFAULT, as in the following C# example:
theRecgonizerContext.Factoid = "(!IS_DEFAULT)";
For applications that use the InkEdit control, set the factoid type for the control by specifying:
InkEdit1.Factoid = "(!IS_INPUTSCOPE)"
Where IS_INPUTSCOPE is the name of the input scope you wish to apply.
The InkEdit control does not expose a RecognizerContext object. Context can still be assigned by using the InkEdit.Factoid property, but the WORDMODE flag cannot be set.