I don't understand the class TextCompositionEventArgs.
There are members of type string named ControlText,SystemText,Text. Then there is a field TextConmposistion which itself contains the members ControlText, SystemText and Text again and additionally the fields SystemCompositionText and CompositionText.
public class TextCompositionEventArgs : InputEventArgs
{
..
public string ControlText { get; }
public string SystemText { get; }
public string Text { get; }
public TextComposition TextComposition { get; }
}
public class TextComposition : DispatcherObject
{
..
public string CompositionText { get; protected set; }
public string ControlText { get; protected set; }
public string SystemCompositionText { get; protected set; }
public string SystemText { get; protected set; }
public string Text { get; protected set; }
}
Both Text members seem to contain the text typed with the keyboard, all other fields contain empty strings.
In which way do these fields differ and what are they good for?
TextCompositionEventArgs deals with changes while composing text, so it has many properties dealing with the text and what specifically is changing, and how you use it depends on what events you're handling.
The basic things to understand:
Text: This contains that actual text that caused the event - normally the user's typed text
SystemText: This contains system text events, ie: if you hit Alt+letter, you'll see the event here. This is normally keystrokes that wouldn't effect text in a control like a text box.
ControlText: This is control text events, ie: if you hit Ctrl+letter, you'll see it here. Similar to SystemText.
Normally, if you're just looking for standard "text" events, you'll just want to look at the "Text" property. For details, see the Input Overview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With