I’m playing with the solutionModel and have come across something I can’t wrap my mind around. I create 3 forms: formMain, formBP, and formResult. I create 2 tab panels on formMain for each of the other forms. I’ve created 3 buttons on formBP. 2 of them set the designMode for formResult to true or false. Those buttons work fine. I have created a method for the thrid button so that when it is pushed it will create a label on formResult. I’m having trouble structuring this method. I’ve run into the ‘stale forms…’ error along with other other errors as I try different approaches, though still ultimately getting nowhere. Any help is appreciated.
Thanks, Marc. I’m running 5.1.1, so using controller.recreateUI() got rid of my ‘stale forms’ error. That has led me to another question. Here is the code I am using for my three buttons:
var enter = "function enterDM(event) {";
enter += " forms['formResult'].controller.setDesignMode(true);";
enter += "};";
enterDMMethod = buttonForm.newFormMethod(enter);
enterButton = buttonForm.newButton('Enter DM',20,0,83,30,enterDMMethod);
var exit = "function exitDM(event) {";
exit += " forms['formResult'].controller.setDesignMode(false);";
exit += "};";
exitDMMethod = buttonForm.newFormMethod(exit);
exitButton = buttonForm.newButton('Exit DM',140,0,83,30,exitDMMethod);
var newLabel = "function newLabel(event) {";
newLabel += " var objectiveForm = solutionModel.getForm('formResult');";
newLabel += " history.removeForm('formResult');";
newLabel += " solutionModel.removeForm('formResult');";
newLabel += " var inputDiag = plugins.dialogs.showInputDialog('Enter Label Tool Tip text.','When you hover your mouse over the label, your entered text will appear.',null);";
newLabel += " var label = objectiveForm.newLabel('',20,30,6,6);";
newLabel += " label.background = '#FF0000';";
newLabel += " label.name = 'lbl_' + inputDiag;";
newLabel += " label.toolTipText = inputDiag;";
newLabel += " forms['formResult'].controller.recreateUI();";
newLabel += "};";
var newLabelMethod = buttonForm.newFormMethod(newLabel);
var newLabelButton = buttonForm.newButton('New Label',260,0,83,30,newLabelMethod);
When I push button ‘New Label’ the first time I get my label and it works great. I enter design mode and move the label, then exit design mode and it stays where I left it. When I push ‘New Label’ a second time, I moves the existing label back to it’s original location and creates a second label on top of it. How can I keep it from repositioning my labels?
gldni:
When I push button ‘New Label’ the first time I get my label and it works great. I enter design mode and move the label, then exit design mode and it stays where I left it. When I push ‘New Label’ a second time, I moves the existing label back to it’s original location and creates a second label on top of it. How can I keep it from repositioning my labels?
Didn’t use designmode yet. If I’m not mistaken (from what I heard at the 5.0 kickoff presentation):
Designmode is just a ‘mode’ to enable a client to do some formdesign, BUT…
changes are not automatically stored, that’s the part where you have to jump in and write code to do that.
Then calling your code from the button, you have to take the changes you stored into account.