22.7.11 Xwidget 事件

Xwidget(see Embedded Native Widgets)可以发送事件,以向 Lisp 程序更新其状态。 这些事件称为 xwidget-event,包含描述变更性质的各种数据。

(xwidget-event kind xwidget arg)

每当 xwidget 中发生某种更新时,都会发送该事件。 更新有多种类型,由 kind 标识。

这是一种特殊事件(see 特殊事件), 应通过为 xwidget 添加回调函数来处理, 每当接收到针对 xwidget 的 xwidget 事件时都会调用该回调。

你可以通过设置 xwidget 属性列表中的 callback 来添加回调, 该回调应为接受 xwidgetkind 作为参数的函数。

load-changed

该 xwidget 事件表示 xwidget 已到达页面加载过程的特定阶段。 发送这些事件时,arg 包含一个字符串,进一步描述组件的状态:

load-started

表示组件已开始执行页面加载操作。

load-finished

表示 xwidget 已完成之前正在执行的页面加载操作。

load-redirected

表示 xwidget 在页面加载过程中遇到并跟随了重定向。

load-committed

表示 xwidget 在页面加载过程中已确定使用给定 URL, 即该 URL 是当前页面加载操作中 xwidget 最终渲染的 URL。

download-callback

该事件表示某种下载已完成。

在上述事件中,arg 之后可以有更多参数: arg 本身表示下载文件的来源 URL; arg 后的第一个参数表示下载的 MIME 类型(字符串); 第二个参数包含下载文件的完整文件名。

download-started

该事件表示下载已开始。 在这些事件中,arg 包含当前正在下载的文件的 URL。

javascript-callback

该事件包含 JavaScript 回调数据。 这些事件由 xwidget-webkit-execute-script 内部使用。

(xwidget-display-event xwidget source)

每当某个 xwidget 请求显示另一个 xwidget 时,发送该事件。 xwidget 是应被显示的 xwidget, source 是请求显示 xwidget 的 xwidget。

它也是一种特殊事件,应通过回调处理。 你可以通过设置 source 属性列表中的 display-callback 来添加此类回调, 该回调应为接受 xwidgetsource 作为参数的函数。

xwidget 的缓冲区会被设置为临时缓冲区。 显示组件时,应注意使用 set-xwidget-buffer 将缓冲区替换为将要显示该 xwidget 的缓冲区(see Embedded Native Widgets)。


emacs

Emacs

org-mode

Orgmode

Donations

打赏

Copyright

© Jasper Hsu

Creative Commons

Creative Commons

Attribute

Attribute

Noncommercial

Noncommercial

Share Alike

Share Alike