Copy link to clipboard
Copied
@hi there,
Anyone knows how to disable tab from tabbed panel when clicked on a button?
I noticed that my tab does turn gray/black when it was disabled/enabled unless i clicked on it.
How to make it refresh automatically when clicked?
@
Thanks...
code below:
var w = new Window ("dialog", "test", undefined, {closeButton: false});
w.alignChildren = "right";
var tpanel = w.add ("tabbedpanel");
tpanel.alignChildren = ["fill", "fill"];
tpanel.preferredSize = [350,300];
var general = tpanel.add ("tab", undefined, "Text");
var images = tpanel.add ("tab", undefined, "Images");
var buttons = w.add ("group");
buttons.add ("button", undefined, "close", {name: "ok"});
hide = buttons.add ("button", undefined, "disable 'Images' ");
hide.onClick = function(){
images.enabled =false;
}
w.show ();
Copy link to clipboard
Copied
What do you mean by 'How to make it refresh automatically when clicked?'?
Peter
Copy link to clipboard
Copied
hi.. sorry for the late response.
what i meant is that when i clicked on the disable 'Images' button, the image tab's text is still enabled until i clicked on it then it'll appear grey (disabled) state.
ideally the moment the disabled images button was clicked it should turn@ grey.
Copy link to clipboard
Copied
i'm using Indesign CS6.
Copy link to clipboard
Copied
Ok, I understand now and can reproduce it but have no idea how to get around it. Looks like a bug in CS6 to me. In CC2017 it works fine, must be one of the very few (ScriptUI) things that got better after CS6!
Peter
Copy link to clipboard
Copied
noted.. Thank you
Copy link to clipboard
Copied
Hi eboda_snaf,
As often with ScriptUI this is a redraw issue. In CS4-CS6 the 'tab' widget—which by the way is a formal Panel instance—doesn't gray its label out when the enabled property changes. So you need to help it a bit. An option would be to hide() & show() the whole TabbedPanel component but that might be unnecessarily heavy. I found that temporarily changing the label (text) does the trick.
Best is to ‘prototype’ that tool:
Panel.prototype.refresh = function( t)
{
// Stupid op to force the tab to redraw.
// ---
this.text = (t=this.text) + '|';
this.text = t;
};
Then, in your code, just add images.refresh(); after disabling/enabling.
If this doesn't work, use tpanel.hide(); images.enabled=false; t.panel.show(); instead.
@+
Marc
Copy link to clipboard
Copied
Hi, I Just Modify the Hide.onClick Function, Now it can Enable and Disable and Vice Versa :
hide.onClick = function(){
if(images.enabled== true) {
images.enabled=false;
hide.text = "Enable Images";
}else{
if(images.enabled== false) {
images.enabled=true;
hide.text = "Disable Images";
}
}
}