Skip to main content
subieguy2
Inspiring
November 6, 2018
Question

Increment button creation placement

  • November 6, 2018
  • 0 replies
  • 403 views

I am creating buttons on a page based on if a layer exist or not. Not all layers will be in every document. How do I increment the buttons being created so that they will be stacked and have just a little space between each?

Here is the script I have written with just creating them at the size I need.... but they obviously stack right on top of each other.

var inch = 72;

for (var p = this.numPages - 1; p >= 0; p -= 2) {

    var buttonPlace = this.getPageBox({

        nPage: p

    });

    for (var i = 0; i < ocgArray.length; i++) {

        if (ocgArray.name == "No Color") {

            buttonPlace[2] = 0.5 * inch;

            buttonPlace[0] = buttonPlace[2] + 0.868 * inch;

            buttonPlace[1] = 30 * inch;

            buttonPlace[3] = buttonPlace[1] + 0.11 * inch;

            var f = this.addField(ocgArray.name, "button", p, buttonPlace)

            f.setAction("MouseUp", "noColor();");

        }

        if (ocgArray.name == "Black (Ground)") {

            buttonPlace[2] = 0.5 * inch;

            buttonPlace[0] = buttonPlace[2] + 0.868 * inch;

            buttonPlace[1] = 30 * inch;

            buttonPlace[3] = buttonPlace[1] + 0.11 * inch;

            var f = this.addField(ocgArray.name, "button", p, buttonPlace)

            f.setAction("MouseUp", "ground();");

        }

        if (ocgArray.name == "032 (Red)") {

            buttonPlace[2] = 0.5 * inch;

            buttonPlace[0] = buttonPlace[2] + 0.868 * inch;

            buttonPlace[1] = 30 * inch;

            buttonPlace[3] = buttonPlace[1] + 0.11 * inch;

            var f = this.addField(ocgArray.name, "button", p, buttonPlace)

            f.setAction("MouseUp", "zeroThreeTwo();");

        }

    }

}

This topic has been closed for replies.