Selection

Selection

概述

Selection 是 Aspose.Html FOSS 中用于 Python 的类。

文档范围的选择,采用单区间语义。

此类提供 12 个方法,用于在 Python 程序中处理 Selection 对象。可用的方法包括:__init__, add_range, collapse, collapse_to_end, collapse_to_start, contains_node, extend, get_range_at, remove_all_ranges, select_all_children, set_position, to_string。在安装 Aspose.Html FOSS for Python 包后,所有公共成员对任何 Python 应用程序均可访问。属性:anchor_node, anchor_offset, focus_node, focus_offset, is_collapsed, range_count。

属性

名称类型访问描述
range_countint读取此选择中的范围数量(0 或 1)。
anchor_node`“NodeNone”`读取
anchor_offsetint读取当前选择方向的锚点偏移。
focus_node`“NodeNone”`读取
focus_offsetint读取当前选择方向的焦点偏移。
is_collapsedbool读取True 当选区为空或底层范围已折叠时。

方法

签名描述
__init__(owner_document: "Document")Calls init在此 Selection 实例上 (owner_document)。
get_range_at(index: int) → "Range"返回选定的范围位于 index.
add_range(range_obj: "Range")将此选区的单个范围设置为 range_obj.
remove_all_ranges()清除当前选择。
`collapse(node: “NodeNone”, offset: int)`
`set_position(node: “NodeNone”, offset: int)`
collapse_to_start()将选择折叠为当前起始边界点。
collapse_to_end()将选区折叠到当前结束边界点。
select_all_children(node: "Node")选择所有子项 node.
extend(node: "Node", offset: int)将选区焦点移动到 (node, offset).
to_string() → str返回所选范围的纯文本内容。
contains_node(node: "Node", allow_partial_containment: bool) → boolReturn True 如果选择包含 node.

另请参阅

 中文