wx.html2.WebView和屏幕阅读器

时间:2019-03-25 20:13:31

标签: wxpython

在wxPython 4.0 Phoenix中,我试图将wx.html2.WebView与屏幕阅读器配合使用。

无论是JAWS还是NVDA,我都必须在Widget上单击鼠标左键,以便能够在可访问的Web界面中查看我的页面。

这是我的代码,但是知道LoadURL方法存在相同的问题。

我是否应该添加一些内容,以便在显示小部件后将焦点直接放在Web界面中?

预先感谢您的回答。

refreshResto() {

    console.log("CREATING GEOQUERY AND CALLBACKS");

    // Cancel previous geoQuery
    if (typeof this.geoQuery !== "undefined")
        this.geoQuery.cancel();

    this.geoQuery = this.geoFire.query({
        center: [this.variablesService.mapPosition.lat, this.variablesService.mapPosition.lng],
        radius: 20
    });

    let key_entered = false;

    // Called when a point is discovered by the query
    this.geoQuery.on("key_entered", (key, location, distance) => {
        key_entered = true;

        console.log("QUERY ON"); // Never printed on iOS

        // Some processing
        // ...
    });

    // Called when geoQuery ends his init process
    this.geoQuery.on("ready", () => {
        console.log("READY !!"); // Never printed on iOS
        if (!key_entered)
            // ...
        else
            // ...
    });

    console.log("GEOQUERY : " + JSON.stringify(this.geoQuery));
}

亲切的问候。

1 个答案:

答案 0 :(得分:0)

在Windows下,由于Internet Explorer Server的一个奇怪错误,您实际上需要单击窗口小部件中的某个位置,以便屏幕阅读器可以与其交互。 进行首次点击后,屏幕阅读器便可以完美地与该小部件配合使用。

请注意,最新的wxWidgets 3.1.3在C ++中仍然会发生相同的问题。 实际上,此错误也不由wxWidgets和wxPython负责。直接使用ActiveX和Win32 API嵌入Internet Explorer Server时也会发生这种情况。

您可以生成所需的初始鼠标单击,以便通过以下方式访问小部件:

robot = wx.UIActionSimulator() 
self.browser.SetFocus() 
position = self.browser.GetPosition() 
position = self.browser.ClientToScreen(position) 
robot.MouseMove(position) 
robot.MouseClick() 

wx.UIActionSimulator是一个类,它允许像机器人一样生成用户事件。通常,它用于演示,UI自动测试或重放记录的宏。 在这里,我们使用它来进行所需的鼠标单击。 类似的解决方案也适用于C ++。

  1. 我们将焦点设置到小部件
  2. 我们得到它相对于窗口的左上角位置
  3. UIActionSimulator需要绝对的屏幕坐标,因此我们需要转换位置
  4. 我们移动鼠标并单击

通过单击窗口小部件的最左上角的位置,不太可能产生不希望的效果,而并非完全不可能。