• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to listen for document events that user triggers while palette window is open

New Here ,
Apr 17, 2017 Apr 17, 2017

Copy link to clipboard

Copied

Hello all,

Is there a way to listen for document events that the user triggers while a palette window is open?

I have looked at the documentation for something like `document.addEventLister` or something, but I have not found anything.

For example, I want to listen for the Paint Brush Tool and update my open palette window ui based on that.

Here is what I have tried:

var isDone, s2t, waitForRedraw, win, windowResource;

var count = 0;

var document;

// Shortcut function

s2t = function(stringID) {

  return app.stringIDToTypeID(stringID);

};

waitForRedraw = function() {

  var d;

  d = new ActionDescriptor();

  d.putEnumerated(s2t('state'), s2t('state'), s2t('redrawComplete'));

  return executeAction(s2t('wait'), d, DialogModes.NO);

};

//sentinel variable

isDone = false;

windowResource = "palette {  \    orientation: 'column', \    alignChildren: ['fill', 'top'],  \    preferredSize:[130, 130], \    text: 'Brush Stroke Counter 1.0',  \    margins:15, \    \    sliderPanel: Panel { \        orientation: 'row', \        alignChildren: 'right', \        margins:15, \        text: ' Brush Stroke Count ', \        st: StaticText { text: '0', characters: 5, justify: 'left'} \        } \    \    bottomGroup: Group{ \        cd: Checkbox { text:'Count Enabled', value: true }, \        cancelButton: Button { text: 'Close', properties:{name:'cancel'}, size: [120,24], alignment:['right', 'center'] }, \    }\}";

win = new Window(windowResource);

// Button listeners

win.bottomGroup.cancelButton.onClick = function() {

  return isDone = true;

};

win.onClose = function() {

  return isDone = true;

};

win.show();

activeDocument.addEventListener("Pnt ", function(){

     alert("I'm painting!");

});

while (isDone === false) {

 

     //listen for user painting here?

  alert(app.currentTool);

  app.refresh(); // or, alternatively, waitForRedraw();

 

}

Any help is appreciated.

Thank you

TOPICS
Actions and scripting

Views

328

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

Moving to Photoshop Scripting​

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines