Skip to main content
StrongBeaver
Brainiac
January 8, 2017
Answered

Button stays active and no action taken ?

  • January 8, 2017
  • 1 reply
  • 1052 views

When clicking on the 'Group Invert' button; the button remains active and nothing happens when the follow script is applied to a group.

var ui = new Window ("dialog");

var uiConvert = ui.add("button",undefined,"Group Invert");

var uiFind = ui.add("button",undefined,"Group Finder");

  ui.orientation = "row";

ui.show();

uiConvert.onClick = function() {

var mDoc = app.documents[0];

  var nGroup = mDoc.groupItems[0].selected;

if (nGroup >= 0) {

app.executeMenuCommand("ungroup");

}

};

This topic has been closed for replies.
Correct answer o-marat

ui.show() must be placed after uiConvert.onClick event handler:

var ui         = new Window("dialog");

var uiConvert  = ui.add("button", undefined, "Group Invert");

var uiFind     = ui.add("button", undefined, "Group Finder");

ui.orientation = "row";

uiConvert.onClick = function() {

  var mDoc   = app.documents[0];

  var nGroup = mDoc.groupItems[0].selected;

  if (nGroup >= 0) {

    app.executeMenuCommand("ungroup");

  }

}

ui.show();

everything else is good

1 reply

o-marat
o-maratCorrect answer
Inspiring
January 8, 2017

ui.show() must be placed after uiConvert.onClick event handler:

var ui         = new Window("dialog");

var uiConvert  = ui.add("button", undefined, "Group Invert");

var uiFind     = ui.add("button", undefined, "Group Finder");

ui.orientation = "row";

uiConvert.onClick = function() {

  var mDoc   = app.documents[0];

  var nGroup = mDoc.groupItems[0].selected;

  if (nGroup >= 0) {

    app.executeMenuCommand("ungroup");

  }

}

ui.show();

everything else is good

StrongBeaver
Brainiac
January 8, 2017

The UI has to encapsulate everything

Although why does the button after triggered stay enabled or "blue" ?

o-marat
Inspiring
January 8, 2017

I think it's a good questions to Adobe developers