简体   繁体   English

在acrobat PDF中分配mouseUp事件

[英]Assign mouseUp event in acrobat PDF

I am working with JavaScript in Adobe Acrobat and want to assign a mouseUp event to multiple fields on document load. 我正在Adobe Acrobat中使用JavaScript,并希望在文档加载时将mouseUp事件分配给多个字段。 Is that possible or do I have to go into each field and manually select properties -- > Actions and so on ? 这是否可行,还是我必须进入每个字段并手动选择属性->操作等?

I imagine something like this 我想像这样

var fg = this.getField(nameOfFieldGroup).getArray();

for (var i = 0; i < fg.length; i++) {
    if (this.getField(fg[i]).required) {
        // assign a mouseUp event to that field here.
    }
}

The Field.setAction() method will let you add scripts to a field. Field.setAction()方法将使您可以将脚本添加到字段中。 You only need to do this once, not every time the document loads. 您只需要这样做一次,而不是每次加载文档时都这样做。 The script in the second parameter is the string that you want to be executed when the specified event fires. 第二个参数中的脚本是在指定事件触发时要执行的字符串。 In the example below, it's just a beep. 在下面的示例中,这只是哔哔声。

this.getField(fg[i]).setAction("MouseUp", "app.beep(0);");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM