Mobile app version of vmapp.org
Login or Join
Shanna688

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

@Shanna688

Posted in: #AdobePhotoshop #PhotoshopScripting

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 :)

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shanna688

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini998

No, if you want this data then its time to wirte a plugin in C++.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme