app.document.chooseMenuItem(); will not work in an onClick() function
This fault was reported 7 years ago but still not fixed.
https://feedback.photoshop.com/photoshop_family/topics/bridge_choosemenuitem_command_does_not_work_in_an_onclick_function
Same example...
target bridge
var w = new Window('dialog');
w.bu1 = w.add('button',undefined,'Info');
w.bu1.preferredSize=[60,30];
w.bu2 = w.add('button',undefined,'Cancel');
w.bu2.preferredSize=[60,30];
//this will work here
app.document.chooseMenuItem("mondo/command/about");
w.bu1.onClick=function(){
//Will not work here, this applies to all chooseMenuItem commands.
app.document.chooseMenuItem("mondo/command/about");
alert("Command given to show about");
}
w.show();
![](https://secure.gravatar.com/avatar/a60dd7a8b2b3e570d86d81e353134f5e?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
PECourtejoie commented
Please Bridge Team, listen to coders, we non-scripters rely on their ability to help us!
-
Kukurykus commented
You may use palette together with BridgeTalk as workaround:
function bS() {
win = new Window('palette');
function wa(v) {return win.add('button', [0, 0, 0, 0], v)}
for(i = 0; i < (elements = ['About', 'Cancel']).length;){
wa(elements[i++]).onClick = function() {
if (this.text == arr[1]) win.close() else
app.document.chooseMenuItem
('mondo/command/about')
}
}
win.show()
}function cnt(v) {return 'bS=' + v + ';bS()'}
(bt = new BridgeTalk()).target = 'bridge'
bt.body = cnt(bS.toSource()), bt.send(2)Also please link to this solution on PF, as I'm banned on that forum from several months :(
btw. Forum Bridge Team, please take care of opportunity to make codes indentation, THX!