如何向我的RichText编辑器中的偏移量包含链接的UI自动化客户端公开? [英] How do I exposed to a UI Automation Client that an offset in my RichText editor contains a link?

查看:68
本文介绍了如何向我的RichText编辑器中的偏移量包含链接的UI自动化客户端公开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何向我的RichText编辑器中的偏移量包含链接的UI自动化客户端公开?


我在C#WPF应用程序中有一个自定义的RichText编辑器。 / p>

什么界面会公开这些信息? ITextRange? ITextRangeProvider?


当使用屏幕阅读器时,我注意到当使用写字板时,如果我向上或向下箭头指向包含"搜索引擎
www.bing.com "我会听到"搜索引擎链接
www.bing.com 。" 请注意"link"一词已添加。


我想在逐行上下导航时在我的自定义RichText编辑器中实现相同的行为。


当我向右箭头通过写字板中的文本,屏幕阅读器不会说"链接"。当插入符号到达第一个"w"时在" www.bing.com "中。


我想实施的说法&]连结"当插入符号到达URL中的第一个字符时。


我假设当用户使用向左或向右箭头键导航时,UIA客户端将使用TextUnit.Character调用ITextRangeProvider.Move。


然后通过其他一些UI自动化手段,屏幕阅读器可以确定TextRange上有一个链接。 这是怎么做到的?


我看到客户端可以调用ITextProvider.RangeFromChild,它"检索包含子元素的文本范围,例如图像,超链接或其他嵌入对象。"   UIA客户端是否会遍历该范围并找到该链接? 如果
如此,是否有关于如何执行此操作的示例?



解决方案

您好,


使用CodedUI使用以下代码段


string  hyperlink = @" https://social.msdn.microsoft.com" ;;


WpfHyperlink wpfHyperlink = new WpfHyperlink(WpfWindow);

                wpfHyperlink.SearchProperties [WpfHyperlink.PropertyNames.Name] =超链接;

                if(wpfHyperlink == null)

                {

                    Console.WriteLine("超链接或URL未找到 - "+超链接);

                   返回false;

                }¥b $ b                Console.WriteLine("未找到超链接或URL - +"超链接);



How do I exposed to a UI Automation Client that an offset in my RichText editor contains a link?

I have a custom RichText editor in a C# WPF application.

What interface would expose such information? ITextRange? ITextRangeProvider?

When using a screen reader, I noticed when using WordPad if I up or down arrow to a line of text that contains "The search engine www.bing.com" I will hear "The search engine link www.bing.com."  Notice the word "link" was added.

I would like to implement the same behavior in my custom RichText editor when navigating up and down by line.

When I right arrow through the text in WordPad, the screen reader does NOT speak "link" when the caret reaches the first "w" in "www.bing.com".

I would like to implement the speaking of "link" when the caret reaches the first character in the URL.

I assume the UIA client would call ITextRangeProvider.Move with TextUnit.Character when the user navigates with the left or right arrow keys.

Then through some other UI Automation means, the screen reader could determine there is a link at the TextRange.  How is this done?

I see the client can call ITextProvider.RangeFromChild which "Retrieves a text range enclosing a child element such as an image, hyperlink, or other embedded object."  Does the UIA client then iterate through the range and find the link? If so, is there an example on how to do so?

解决方案

Hi,

Use following snippet, using CodedUI

string hyperlink = @"https://social.msdn.microsoft.com";

WpfHyperlink wpfHyperlink = new WpfHyperlink(WpfWindow);
                wpfHyperlink.SearchProperties[WpfHyperlink.PropertyNames.Name] = hyperlink;
                if (wpfHyperlink == null)
                {
                    Console.WriteLine("Hyperlink or URL not found - " + hyperlink);
                    return false;
                }
                Console.WriteLine("Hyperlink or URL not found - " + hyperlink);


这篇关于如何向我的RichText编辑器中的偏移量包含链接的UI自动化客户端公开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆