MouseEvent
MouseEvent
概述
MouseEvent 是 Aspose.Html FOSS 中用于 Python 的类。继承自:UIEvent。
鼠标或指针事件(WHATWG UI Events §5.2)。
此类提供 5 个方法,用于在 Python 程序中处理 MouseEvent 对象。可用的方法包括:__init__、init_event、prevent_default、stop_immediate_propagation、stop_propagation。在安装了 Aspose.Html FOSS for Python 包之后,所有公共成员对任何 Python 应用程序均可访问。属性:alt_key、bubbles、button、buttons、cancelable、client_x,以及其他 19 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
button | int | 读取 | 哪个鼠标按钮被按下(0 = 主按钮,1 = 中键,2 = 次按钮)。 |
buttons | int | 读取 | 当前所有被按下的鼠标按钮的位掩码。 |
client_x | int | 读取 | 相对于视口的水平坐标。 |
client_y | int | 读取 | 相对于视口的垂直坐标。 |
screen_x | int | 读取 | 相对于屏幕的水平坐标。 |
screen_y | int | 读取 | 相对于屏幕的垂直坐标。 |
offset_x | int | 读取 | 相对于目标元素内边距边缘的水平偏移(始终为 0)。 |
offset_y | int | 读取 | 相对于目标元素内边距边缘的垂直偏移(始终为 0)。 |
page_x | int | 读取 | 相对于文档的水平坐标(在无头模式下始终为 0)。 |
page_y | int | 读取 | 相对于文档的垂直坐标(在无头模式下始终为 0)。 |
alt_key | bool | 读取 | 事件触发时 Alt 键是否处于激活状态。 |
ctrl_key | bool | 读取 | 事件触发时 Ctrl 键是否处于激活状态。 |
meta_key | bool | 读取 | 事件触发时 Meta 键是否处于激活状态。 |
shift_key | bool | 读取 | 事件触发时 Shift 键是否处于激活状态。 |
related_target | `“object | None”` | 读取 |
detail | int | 读取 | 与事件关联的整数细节值。 |
view | None | 读取 | 始终在无头模式下 None(窗口回溯超出范围)。 |
type | str | 读取 | 事件类型字符串。 |
bubbles | bool | 读取 | 事件是否冒泡。 |
cancelable | bool | 读取 | 是否可以阻止默认行为。 |
target | `“EventTarget | None”` | 读取 |
current_target | `“EventTarget | None”` | 读取 |
event_phase | int | 读取 | 阶段常量:NONE (0), CAPTURING_PHASE (1), AT_TARGET (2), BUBBLING_PHASE (3)。 |
default_prevented | bool | 读取 | 是否在可取消的事件上调用了 preventDefault()。 |
timestamp | float | 读取 | 事件创建时的 Unix 纪元时间(秒)。 |
方法
| 签名 | 描述 |
|---|---|
__init__(type: str, bubbles: bool, cancelable: bool, detail: int, button: int, buttons: int, client_x: int, client_y: int, screen_x: int, screen_y: int, alt_key: bool, ctrl_key: bool, meta_key: bool, shift_key: bool, related_target: object) | Calls init(type, bubbles, cancelable, detail, button, buttons, client_x, client_y, screen_x, screen_y, alt_key, ctrl_key, meta_key, shift_key, related_target) 在此 MouseEvent 实例上。 |
prevent_default() | 如果事件是可取消的,请将 default_prevented 设置为 True。 |
stop_propagation() | 在当前目标上的所有监听器完成后,停止事件传播。 |
stop_immediate_propagation() | 停止传播并阻止当前目标上剩余的监听器。 |
init_event(type: str, bubbles: bool, cancelable: bool) | 用于预分派事件初始化的旧别名。 |