/* * アプリ内で持っているテキストが欲しいと言ってきた。 * CoreTextEditContextを作るとこれが呼ばれます。 */ private void EditContext_TextRequested(CoreTextEditContext sender, CoreTextTextRequestedEventArgs ev) { // TextBlockの中のカーソル以外のRunの文字からテキストを作ります。 ev.Request.Text = new string((from x in EditText.Inlines where x != Cursor select((Run)x).Text[0]).ToArray()); Debug.WriteLine("<<--- TextRequested : {0}-{1} [{2}]", ev.Request.Range.StartCaretPosition, ev.Request.Range.EndCaretPosition, ev.Request.Text); }
// Return the specified range of text. Note that the system may ask for more text // than exists in the text buffer. void EditContext_TextRequested(CoreTextEditContext sender, CoreTextTextRequestedEventArgs args) { CoreTextTextRequest request = args.Request; request.Text = _text.Substring( request.Range.StartCaretPosition, Math.Min(request.Range.EndCaretPosition, _text.Length) - request.Range.StartCaretPosition); }
/* * アプリ内で持っているテキストが欲しいと言ってきた。 * CoreTextEditContextを作るとこれが呼ばれます。 */ private void EditContext_TextRequested(CoreTextEditContext sender, CoreTextTextRequestedEventArgs ev) { ev.Request.Text = StringFromRange(ev.Request.Range.StartCaretPosition, ev.Request.Range.EndCaretPosition); Debug.WriteLine("<<--- TextRequested : {0}-{1}", ev.Request.Range.StartCaretPosition, ev.Request.Range.EndCaretPosition); }
// Return the specified range of text. Note that the system may ask for more text // than exists in the text buffer. void EditContext_TextRequested(CoreTextEditContext sender, CoreTextTextRequestedEventArgs args) { CoreTextTextRequest request = args.Request; request.Text = _text.Substring( request.Range.StartCaretPosition, Math.Min(request.Range.EndCaretPosition, _text.Length) - request.Range.StartCaretPosition); }