I'm having two new issues and hope you can help me with them:
***
Background:
- I am using this with FrameMaker, but it is esssentially a ScriptUI question.
- As I now understand it, palette windows remain open until I exit FrameMaker, they can be hidden, but they still exist in memory.
- Many of my windows use the same names for buttons/controls, which doesn't seem (read on) to cause any issues.
- We have about 10 document templates.
- I created essentially two palette dialogs for each template. One turns on and off conditional text (among other features) and one updates variables. The scripts are revised as above to only create one window - if it doesn't exist, it creates it. If it does exist, it re-opens it.
- I have a separate script that checks for any of the windows and closes the window if it is open, then reads a variable in the document and opens the correct conditional text palette.
- Each conditional text palette has a panel with checkboxes. These panels have a button labelled "Select All" and "Single Select." Neither of these are radio buttons, but they act like it - i.e. if I click "Select All", it deselects "Single Select" and either selects or deselects all the other buttons in the panel. If I click SingleSelect, it deselects SelectAll and each button acts like a radio button.
***
Issues:
- I open DocA and the ShowConditonal text window works fine and the Select All and Single Select buttons work fine. I open DocB and the ShowCondiitional Text Window for DocB works fine and the Select All and Single Select buttons work fine. I switch back to DocA and re-open the ShowConditional Text window and the Select All and Single Select buttons no longer work. I can click Select All and nothing changes, I click Single Select and everything is deselected, but SelectAll remains Selected. Closing and re-opening the pallete doesn't resolve the issue. Essentially it doesn't work again until I close and re-open FrameMaker. DocB still works correctly. (If I swap the order, it swaps, i.e. if I open DocB first and then open DocA, DocB stops working, but DocA still works).
- Issue2: Less common, but the scripts check the active document - i.e. if I am working on a DocA template document and have the DocB show Conditional text window open, the script should pop-up "The active document is not using the Doc B template" and does not perform the action. Sometimes, I will be working on DocA, have the DocA Show Conditional text window open, and will still get the "Active Document is not using Doc B" message. This seems to only happen when I have opened several different documents in FrameMaker. Again, closing FM and re-opening it seems to be the only way to get things working properly again.
***
UPDATE: I did a test and found that if I change the DocB script and re-name Ckbx_SelectAll as CkBx_SelectAll_DocB througout, (and Ckbx_SingleSelect to Ckbx_SingleSelect_DocB) the issue is resolved (the first issue). So the questions now become:
- Why was this required for these checkboxes?
- Ideally, do I need to go through each of the scripts and make sure ALL the butttons and checkboxes use unique names?
Issue 1 sounds as if it's still a problem with variable scope. Maybe check you variable (non-)declarations again.
> do I need to go through each of the scripts and make sure ALL the butttons and checkboxes use unique names?
That might be a good idea. But you can target specific controls by looking for them in specifuc windows. Use .find() to find a window, then use find() to find a named contro, in the window.
But another way of organising variables is to use a variable for a window, then declare the window's controls not as autonomous variables but as properties of the window. Something along these lines:
var w1 = new Window ("palette", "Window 1");
w1.btn = w.add ("button", undefined, "OK");
w1.ckbx = w.add("checkbox", undefined,"Check Box");
w1.add ("button", undefined, "Cancel");
w1.btn.onClick=function(){
alert("You clicked OK on Window 1");
}
w1.show();
You can the define your second window simply by copying w1 and replacing w1 with w2.
The advantage of this approach is that you won't run into problems of variable scope and ambiguity.