WPS 基础接口 > 演示 API 参考 > Application > 事件 > Application.WindowBeforeRightClick 事件
右键单击某个形状、幻灯片、备注页或某些文本时发生此事件。此事件由 MouseUp 事件触发。

语法

表达式.WindowBeforeRightClick(Sel, Cancel)

表达式   一个代表 Application 对象的变量。

参数

名称 必选/可选 数据类型 描述
Sel 必选 Selection 发生右键单击时鼠标指针下方的选定内容。
Cancel 必选 Boolean 当事件发生时为 False。如果事件过程将此参数设为 True,则完成此过程后不会出现默认的上下文菜单。

示例

以下示例将创建选定形状的一个副本。如果该形状有文本框,则将文本“Duplicate Shape”添加到新形状中。将 Cancel 参数设置为 True 可以避免出现上下文菜单。

示例代码
function Application_WindowBeforeRightClick(Sel, Cancel) {
    let shaperange = ActivePresentation.Selection.ShapeRange
    if(shaperange.HasTextFrame) {
        shaperange.Duplicate().TextFrame.TextRange.Text = "Duplicate Shape"
    }
    else {
        shaperange.Duplicate()
    }
    Cancel = true
}


请参阅