Help with getting values out of custom dialog
Here is my situation.
I have created a custom tool button which when pressed will acitvate the dialog.
When the info has been entered and the dialog is closed the values saved in the dialog will be written our in a free text annotation.
I can create the button.
I have created the dialog.
I can print out the stored values to the console so I know everything is working as it should be.
Now where I am stuck is getting those values to the annotation. I have been reading all the documentation but can't make anything work.
If someone could please point me in the right direction on how to access stored variables in the dialog object I would greatly appreciate.
The code itself works fine. It's just the skeleton right now. I will beef it up later. just can't figure out how to pass the values to the annotation function. I have tried putting the annotation inside the commit method but that just gave me an error saying it wasn't a function so I tried moving it outside which is where my code stands now.
Everything can be run from the javascript console.
Thanks in advance for any help you can give.
Here is my code for the dialog object. and annotation.var TestDlg1 =
{
initialize: function(dialog)
{
// set a default value for radio groups
dialog.load(
{
"rad1": true,
"rad4": true,
"rad7": true
});
this.hasfta = false;
// disable the fta case# field
dialog.enable(
{
"fta1" : this.hasfta
});
},
rad7: function (dialog) {
// Process the fta, if the user selects yes enable the fta case# field
this.hasfta = !this.hasfta;
dialog.enable({
"fta1" : this.hasfta
});
},
commit:function (dialog) { // called when OK pressed
var results = dialog.store();
// check to see if variables are stored
//console.println("DD1 is " + results["ddt1"] + "and the diary date remarks are " + results["ddr1"])
//console.println("DD2 is " + results["ddt2"] + "and the diary date remarks are " + results["ddr2"] );
var mytext = results["ddt1"]; // try to assign the variables to access outside the dialog
var mytext2 = results["ddr1"];
},
// build my dialog
description:
{
name: "Test Dialog",
elements:
[
{
type: "view",
align_children: "align_left",
elements:
[
{
type: "cluster",
name: "DIARY DATES",
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "DD1",
bold: true,
font: "dialog",
},
{
item_id: "ddt1",
type: "edit_text",
char_width: 20,
height: 20,
width: 80
},
{
type: "static_text",
name: "DDR1",
bold: true,
font: "dialog",
},
{
item_id: "ddr1",
type: "edit_text",
alignment: "align_fill",
width: 200,
height: 20
},
{
type: "static_text",
name: "case#",
bold: true,
font: "dialog",
},
{
item_id: "cse1",
type: "edit_text",
alignment: "align_fill",
width: 200,
height: 20
},
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "DD2",
bold: true,
font: "dialog",
},
{
item_id: "ddt2",
type: "edit_text",
char_width: 20,
height: 20,
width: 80
},
{
type: "static_text",
name: "DDR2",
bold: true,
font: "dialog",
},
{
item_id: "ddr2",
type: "edit_text",
alignment: "align_fill",
width: 200,
height: 20
},
{
type: "static_text",
name: "case#",
bold: true,
font: "dialog",
},
{
item_id: "cse2",
type: "edit_text",
alignment: "align_fill",
width: 200,
height: 20
},
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "DD3",
bold: true,
font: "dialog",
},
{
item_id: "ddt3",
type: "edit_text",
char_width: 20,
height: 20,
width: 80
},
{
type: "static_text",
name: "DDR3",
bold: true,
font: "dialog",
},
{
item_id: "ddr3",
type: "edit_text",
alignment: "align_fill",
width: 200,
height: 20
},
{
type: "static_text",
name: "case#",
bold: true,
font: "dialog",
},
{
item_id: "cse3",
type: "edit_text",
alignment: "align_fill",
width: 200,
height: 20
},
]
},
]
},
{
type:"view",
alignment: "align_left",
align_children: "align_row",
elements:
[
{
type: "cluster",
alignment: "align_left",
name: "ADD FTA?",
align_children: "align_left",
elements:
[
{
type: "radio",
name: "NO",
bold: true,
font: "dialog",
item_id: "rad7",
group_id: "ddrd"
},
{
type: "view",
allignment: "align_left",
align_children: "align_row",
elements:
[
{
type: "radio",
name: "YES",
bold: true,
font: "dialog",
item_id: "rad7",
group_id: "ddrd"
},
{
type: "static_text",
name: "FTA Case#",
bold: true,
font: "dialog"
},
{
type: "edit_text",
item_id: "fta1",
alignment: "align_fill",
width: 200,
height: 20
},
]
},
]
},
{
type: "view",
width: 300,
alignment: "align_left",
align_children: "align_left",
elements:
[
{
type: "ok_cancel",
}
]
},
]
},
]
},
{
type: "view",
align_children: "align_left",
elements:
[
{
type: "cluster",
name: "DL",
elements:
[
{
type: "radio",
item_id: "rad1",
group_id: "dlrd",
name: "NO DL"
},
{
type: "radio",
item_id: "rad2",
group_id: "dlrd",
name: "ADD DL"
},
{
type: "radio",
item_id: "rad3",
group_id: "dlrd",
name: "VALID DL"
},
]
},
{
type: "cluster",
name: "PNTRV",
elements:
[
{
type: "radio",
item_id: "rad4",
group_id: "pvrd",
name: "NO PNTRV"
},
{
type: "radio",
item_id: "rad5",
group_id: "pvrd",
name: "ADD PNTRV"
},
{
type: "radio",
item_id: "rad6",
group_id: "pvrd",
name: "PNTRV VALID"
},
]
}
]
},
]
}
};
//app.execDialog(TestDlg1); this was just for initial testing
if ("ok" == app.execDialog(TestDlg1))
{
// var mytext = results["ddt1"]
// var mytext2 = results["ddr1"]
var mytext3 = "2013-08-25"
var mytext4 = "AGED WARRANT REVIEW"
var mytext5;
var spans = new Array();
spans[0] = new Object();
spans[0].textStyle = "bold";
spans[0].textColor = color.blue;
spans[0].textSize = 10;
spans[0].fontFamily = ["Arial Black", "monospace" ];
// spans[0].text = mytext+"\r" + mytext2+"\r\r"+mytext5+"\r"+mytext; <<<this didn't work
// spans[0].text = TestDlg1.mytext+"\r"+ TestDlg1.mytext2+"\r\r"+mytext5+"\r"+mytext; <<<<this didn't work
// spans[0].text = results["ddt1"] +"\r"+ results["ddr1"] +"\r\r"+mytext5+"\r"+mytext; // this didn't work
spans[1] = new Object();
spans[1].text = "DD1: "+mytext3+"\r"+mytext4;
spans[1].textColor = color.blue;
spans[1].textSize = 20;
spans[1].alignment = "left";
if(mytext5 == ""){ //testing to see if the if statement works
spans[2] = new Object();
spans[2].text = "will soon be here!";
spans[2].textColor = color.green;
spans[2].fontStyle = "italic";
spans[2].underline = true;
spans[2].alignment = "right";
}
// Now create the annot with spans as it's richContents
var annot = this.addAnnot({
page: 0,
type: "FreeText",
rect: [50, 50, 300, 300],
richContents: spans
});
}
Message was edited by: demian seiden code formatting was all messed up in my original post. No indents now but it is much more readable.
