简体   繁体   English

单击另一个旨在显示/隐藏图层的按钮时,在Adobe PDF中隐藏/显示按钮的代码是什么?

[英]What is the code to hide/show a button in Adobe PDF when clicking another button that's purpose is to shows/hides a layer?

I have a button that I edited the action to "run a JavaScript" under "Mouse Down." 我有一个按钮,我在“ Mouse Down”下将操作编辑为“运行JavaScript”。

This is the code I put into the JavaScript (Button is titled "Site External Doors"): 这是我放入JavaScript中的代码(按钮的标题为“站点外门”):

var docOCGs = this.getOCGs(); 
for (var x=0; x < docOCGs.length; x++) 
{
          if(docOCGs[x].name == "Site External Doors" ||
     docOCGs[x].name == "Site External Doors")
          {
                    docOCGs[x].state = !docOCGs[x].state; 
 }
}
// Button Style and Label Change 
if(event.target.borderStyle == border.b)
{
          // Perform Push Down Actions
          event.target.borderStyle = border.i;

          event.target.buttonSetCaption("Site External Doors Off");
} else {
          // Perform Pop Up Actions

          event.target.borderStyle = border.b;

          event.target.buttonSetCaption("Site External Doors On");
}

This code shows a layer when clicked and hides the layer when clicked again. 此代码在单击时显示一个图层,在再次单击时隐藏该图层。 I am wondering what code I need to add to get another button (titled "Door 52") to appear when the button "Site External Doors" is clicked and hide when it is clicked again. 我想知道我需要添加什么代码才能使单击“站点外部门”按钮时出现的另一个按钮(标题为“ 52号门”)出现,并在再次单击时隐藏。

Acroform buttons, like other fields, have a "display" property you can set. 与其他字段一样,Acroform按钮也可以设置“显示”属性。 You should be able to set the "Door 52" button to be hidden on creation, then make it visible with code such as: 您应该可以将“ Door 52”按钮设置为在创建时隐藏,然后通过以下代码使其可见:

// Show the button
var door52 = getField("Door 52");
door52.display = display.visible;

// Hide the button again
door52.display = display.hidden;

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

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