This felt like it should be simple, but!
I'm trying to write a script that overrides the label buttons, so it will label an image but if that label button is pressed again, the label colour won't be removed (the default behaviour using the built in label buttons cmd-6 etc is pressing it again removes the label, which I don't want to do).
Script works ok when viewing thumbnails, it adds a menu option to label a red thumbnail yellow or remove the yellow label and change it back to red and I've also added keyboard shortcuts (MAC OS) to the menu options which works fine.
The problem is it won't work when the slideshow is enabled (CMD-L on a selection of images).
So do I need some sort of listener here so that the keystokes I'm sending to the menu options will work? Or is this a limitation of Bridge? I'm clueless as to how a listener would be scripted.
Here's my test code (all hail my programming skills 😄 ).
if( BridgeTalk.appName == "bridge" ) {
newMenu = new MenuElement( "menu", "Button Label", "after Window", "thisMenu" );
buttonMenuItem1 = new MenuElement( "command", "Remove Yellow Label", "at the end of thisMenu","anAlert" );
buttonMenuItem2 = new MenuElement( "command", "Add Yellow Label", "at the end of thisMenu","anAlert2" );
};
buttonMenuItem1.onSelect = function () {
RemoveYellowLabel();
}
buttonMenuItem2.onSelect = function () {
AddYellowLabel();
}
function RemoveYellowLabel() {
var thumbs = app.document.getSelection("psd, jpg, png, tif, gif");
for(var i = 0;i < thumbs.length;i++)
{
//check if thumbs are labelled or not - if not labelled exit
if (thumbs[i].label =="Second") {
//alert("trapped unlabelled labelled image" + thumbs[i].name + thumbs[i].label);
alert ("yellow label detected");
//"Select" is RED label text in Bridge labels panel
(thumbs[i].label ="Select");
}
}
}
function AddYellowLabel() {
var thumbs = app.document.getSelection("psd, jpg, png, tif, gif");
for(var i = 0;i < thumbs.length;i++)
{
//check if thumbs are labelled or not - if not labelled exit
if (thumbs[i].label =="Select") {
alert ("red label detected");
//"Second" is YELLOW label text in Bridge labels panel
(thumbs[i].label ="Second");
}
}
}