To start lets have a look at a very simple dialog, this dialog
Is produced by the following
description:
{
name: "Errors in form",
elements: [
{
type: "view",
align_children: "align_row",
elements: [
{
type: "static_text",
name: "Please enter your name",
},
{
type: "ok",
}
]
}
]
}
Unfortunately for security reason when used within a Designer form you can't specify the dialog title and you also get a "Warning JavaScript Window". From the console or a Folder Level script you get the dialog without the warnings.
These dialogs can also be used for input (note the addition of a validate function), such as
description:
{
elements: [
{
type: "view",
elements: [
{
type: "static_text",
name: "Please enter your name",
},
{
width: 200,
height: 22,
type: "edit_text",
item_id: "NAME",
},
{
type: "static_text",
item_id: "ERR1",
name: "You must enter your name",
}
]
},
{
type: "ok_cancel",
}
]
},
validate : function(dialog)
{
var isValid = true;
var elements = dialog.store();
if (elements["NAME"] === "")
{
dialog.visible({ERR1:true});
isValid = false;
}
else
{
dialog.visible({ERR1:false});
}
return isValid;
}
Which give this dialog, when the name has been left blank;
This sample, DialogSample.pdf, contains these two dialogs and also one that show most of the controls available and the properties that go with them;
These dialogs have a hierarchy of controls, that is controls within container controls. This quickly becomes a very big form. A form to design a two level dialog contains 3,384 fields, which is enough to get the cooling fans on my computer spinning. So I am posting two forms one that supports two levels of controls and one that supports one level (which is still 1,452 fields).
Dialog.pdf (3893k)
Dialog.L1.pdf (1936k)
The JavaScript code generated is written to an attachment of the form. There is a stub generated for the event handler of each field and a stub for the validate method. Be careful writing code in the validate method as if there is no path that returns true then the only way out of the dialog is using the task manager.
These two samples support a number of controls and properties that are not listed in the manual, but are very useful (in these cases I have made note in the tooltips). Some of the things not documented are;
- link_text: a hyper link control
- mclv: a multi-column list view (or grid)
- slider: a slider but I have not got this to return a value.
- ok_help, ok_cancel_help, ok_other_help, ok_other_cancel_help controls
- separator: draw a line horizontal or vertical with optional caption
- Heading and Title fonts about 10pt and 12pt respectively
- margin_width, margin_height properties for the view control
- back_color, gradient_direction, gradient_type for the view control
- A Dialog.setForeColorRed() method
- A Dialog.visible() method to show/hide controls
Images
This form started life to generate the hex encoded string. This is a representation of a 4 channel (ARGB) 8-bits per channel image, that is 8 JavaScript characters per dot. So images can start to take up a lot of space. You can get the hex encoded string using the importIcon, getIcon and iconStreamFromIcon methods. This sample imposes a size limit an image to about 50,000 dots, this is because Designer has trouble with very long lines and this sample uses an XSLT stylesheet to generate the JavaScript literal and the XSLT processor has a limit of 100 levels of recursion.Fragments
Each dialog control is defined by a fragment and each fragment is used in three levels, and have a smaller width at each level. To override the properties of a fragment you need to use the XML Source view and type in the properties you want to override. For example if the Image fragment had a Border subform and the Border subform had a Propertoes subform then I could override the width values by adding the highlighted XML.<subform usehref=".\Fragments\ImageControl.xdp#som($template.#subform.Image)" w="162.299mm">
<subform name="Border" w="169.298mm">
<subform name="Properties" w="147.299mm"/>
</subform>
</subform>
One down side of this approach is you will now get the warning message "This fragment reference has local overrides to one or more properties of the source fragment".
ToolTips
As there a many fields that use the same tooltip I have created a separate dataset and used the setProperty element to assign them to the correct field. This is done in the XML Source view by adding XML under the xfa:dataset element and referencing them in each form field like "<setProperty target="assist.toolTip" ref="!toolTips.value.[name=="dialogName"]"/>
", which you also need to add using the XML Source view.
Wow! Really impressive work Bruce!
ReplyDeleteTo open the attachment pane automatically add event.target.viewState = {overViewMode:7}; to the preview button script. It's good for people who never can remember key combinations ;-)
ReplyDeleteThanks Radzmar, that is a good enhancement, I've updated the samples to include your suggestion.
ReplyDeleteVery nice
ReplyDeleteThanks, I'm glad you found it useful.
DeleteThanks, this is wonderful work. It helps our projects a lot.
ReplyDeleteYa this is quite amazing. Thanks so much for that AND the trace function! I've been trying to get one like that for awhile now.
ReplyDeleteHi, I'm glad you liked it. The trace function has been growing for some years, I keep adding bits as I need, it might be something I never finish but it has been very handy. Another useful debug tool is the macro at the bottom of a previous post, http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2013/05/javascript-objects-in-xfa-forms.html. This goes though all the code in the form adding a console.println() call that gives you the somExpression of the script and how long it took to execute.
DeleteNice code! Where can I find a tutorial about dialog boxes in an Adobe designer Form with objects, properties and methods?
ReplyDeleteI have not found setForeColorRed method in other tutorials and I want to do similar things (set other colors, set max length to edit_text objects, etc)
Thank you!
Hi Francoise,
ReplyDeleteThere seems to be a lot of properties and methods that aren't documented. Some I've seen other people use, some I came across poking around with the Acrobat JavaScript debugger. Acrobat seems to use these dialogs itself so if you bring up the Acrobat Debugger and type "IWSharedReviewDocCenterCreateID" (without the quotes) you will see an example of one.
I'm sure there are a lot more properties and values to use but they don't seem to be documented, so I guess we have to be careful using them.
Sorry I can't be of more help.
Bruce
Hi,
ReplyDeletejust for information: There is a bug in Acrobat/Reader since version 11.0.7, so all images in the dialogs are blank.
Hi, this is very good work. Thanks for sharing your knowledge with the dialogs with livecycle.
ReplyDeleteI've already made a complex dialog(s) such as a browser through some several items and I've encountered some issue with the dialogs. As for the complex dialogs everything is working fine at the moment.
Right now I'm having some questions about those issues because it is still persisting on other dialogs... which is really annoying...
1st: Is it possible that the dialogs are limited to the object's names such as only chk1 to chk9. Everytime I get to use something like txtHours or anything else than a # its never working. Also I've encountered the issue where I can't have more than 9 checkbox in a dialog, same for buttons, the names which only works are butn, if there is only 1 button and bt:1-9 if there's more than 1 but bt:10 is not working...
See reference button information here: http://www.pdfshareforms.com/how-to-create-nice-dialog-windows-in-pdf-form/
2nd: Is it possible to have a datepicker in the dialogs... I know that the date/time field in the pdf are fine, but my client wants a datepicker in the dialog... Or else my best options is to leave it free text and validate date pattern...
Other than that, your work was great for learning the dialogs, thanks for your time.
Hi Robert, The identifiers used in the dialogs must be exactly 4 characters, the don't have to start with chk, btn or txt or whatever, but they do need to be 4 characters, no more no less.
ReplyDeleteThere are a lot of controls that have not been documented and it would seem strange that they don't have a date picker, but I am not aware of one.
How to get the dialog without the warnings?
ReplyDeleteFrom the console or a Folder Level script you mention.
Please mention example
The folder level scripts are the ones that get copied into the JavaScripts directory under the Acrobat/Reader installation. So are probably only useful within an organisation where you can customise the installation.
DeleteThere is an example in the Acrobat JavaScript API documentation under the trustPropagatorFunction method (see example 2).
http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat9_HTMLHelp&file=JS_API_AcroJS.88.167.html
Hi Bruce, I was wondering if it is possible to give a default value to a drop down list. We have tried to give a default text as :"Choose an option" or to give a value which is inside the data list, but we are unable to insert a value in a drop down list, do you know if it's possible or not?
ReplyDeleteHi there, I have found the solution to my problem. I've notice that the value given in the data list which in occurrence is a number, remains active if the number is above 0 and inactive if equals 0 or under 0.
DeleteTo have a display item such as "Choose an option" selected as default value we have given its value 1. Once the item selected is changed we remove the option "Choose an option" from the data list and assign the value 1 to the selected item from the previous data list into the new one. once that is done, we load back the dialog with the object of the drop down list.. Works fine...
Great work, Bruce. Thanks so much for sharing.
ReplyDeleteI’ve created a simple dialog box which provides additional information to the end-user in a manner that is more organized than a simple messageBox can provide. Doesn’t gather any data.
Within the dialog is a button --- item_id: “btn1”, --- that triggers a messageBox with a little more help, but nothing fancy so a messageBox is fine. Doesn’t gather any data either. Code is in the “commit” of the function ---xfa.host.messageBox(“Little more help.”, “Little Help”);
When btn1 is clicked (from within the dialog) the messageBox opens OVER the dialog box. Perfect!
But when the OKAY of the messageBox is clicked, it closes BOTH the messageBox and the dialog box.
I tested it with the message box having one option (OKAY) and multiple options (OKAY/CANCEL, YES/NO, YES/NO/CANCEL) and that doesn’t seem to make a difference. But that is any interesting question of how to handle returns from a messageBox when the message box is called from within a dialog box.
Advice on how to have the OKAY of the messageBox close only the messageBox? So the dialog box remains open?
Thanks much again.
Brian
Hi Brian,
ReplyDeleteI don't see the behaviour that you are talking about happening in my forms, have a look at this sample. Maybe I am misunderstanding the scenario.
https://sites.google.com/site/livecycledesignercookbooks/home/ALittleMoreHelp.pdf?attredirects=0&d=1
I'm glad you have found this sample useful.
Regards
Bruce
Hi Bruce:
ReplyDeleteWas back on your site today and saw that my reply to your above post wasn't showing - maybe I didn't click "publish" back in December. Just wanted to say thanks. Not sure what I was doing wrong but your example was exactly what I needed.
Thanks again; keep up all the great work.
Brian
Hi Brian, I'm glad I could help. Bruce
DeleteHi Bruce:
ReplyDeleteYou do more than help, amigo. =)
I found my way back to an older adobe forum page where you gave a link: http://thelivecycle.blogspot.com/2010/04/xfa-form-control-view-settings.html
Is that xfa-form-control-view-settings demo still around? I can't seem to access it via the link and not finding it on cookbooks.
Trying to close the "Tools|Fill &Sign|Comment" pane that automatically opens on the right side of the screen. Research suggests completely hiding it can only be done with an application level script but I'm just trying to close it on docOpen.
Thanks again!
Brian
Hi Brian,
DeleteThat's Radzmar's sample but I do have a copy, https://sites.google.com/site/livecycledesignercookbooks/radzmar/LCB_Control_View.pdf?attredirects=0&d=1
Not sure about closing the panels on the right, have only tried closing the ones on the left.
Cheers, Bruce
Bruce:
ReplyDeleteGot it. Thanks much, as always.
Brian
Hey Bruce -
ReplyDeleteAm I going to be your first Reader DC question? lol.
Images that were fine in dialog boxes in Reader 10 & 11 now appear pixelated/"grainy" for for lack of a better word in Reader DC. Possibly due to the size restriction you mentioned above? Just a shot in the dark...
Any early thoughts?
B
Hi Brian,
ReplyDeleteDefinitely my first Reader DC question, I didn't know a new version of Reader was out ... I do like the new look. But I don't see any differences in the images. It wouldn't be the size restriction in my sample as that was in my code. Have you got a pre-release version? I tested some images in version 2015.007.20033 which I have just downloaded.
Regards
Bruce
Maybe there's hope!
ReplyDeleteWe're on the same version (2015.007.20033); I'm on Windows 8.1, but that shouldn't matter, I don't think. Used Acrobat 9.5.5 to open your dialog generator and generate the code.
Here's a link to a side-by-side test - the picture is an accurate representation of the difference: https://www.dropbox.com/s/x14oeudgflnx623/icon%20differences.PNG?dl=0
Left dialog is from Reader DC. RIght is from Acrobat 9.5.5. Icon used is 83 x 83, PNG file.
Was happy with the dialogs I made, thanks to you. Glorified messages boxes in reality, but for me, a victory. They work on all the other Reader versions, except now DC.
Actual test PDF is here: https://www.dropbox.com/s/9hqb4vw6uz6rpg1/icon%20DC%20test.pdf?dl=0
Icon used is: https://www.dropbox.com/s/ffmk3j2dohaoeqx/green%20smiley%2083x83.png?dl=0
Thanks much, as always.
B
Hi,
ReplyDeleteJust tried it on mine and still don't see a difference, https://sites.google.com/site/livecycledesignercookbooks/home/ReaderDC%20Test.PNG?attredirects=0&d=1.
I'm on Windows 7, I'll try Windows 8 tonight, but you wouldn't have thought ...
Thx, B.
ReplyDeleteAdded some more tests into a PDF; link here:
https://www.dropbox.com/s/o3ufyglw3s9od3qicon%20DC%20testMore.pdf?dl=0
Especially apparent on edges of words/letters. Almost wish it just left a blank (no image vs pixelated image)
Curious that it works for you on 7 (no 7 here to test on); interested to see what your 8 or 8.1 test shows,
Will test on Mac 10.9 or 10.10 tonight & let you know.
Fingers crossed; thanks.
B
Link got corrupted, I think. Here it is again.
ReplyDeletehttps://www.dropbox.com/s/o3ufyglw3s9od3q/icon%20DC%20testMore.pdf?dl=0
Just tried on a Windows 8.1 machine and it seems fine, not sure what I could suggest. Maybe worth reporting https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform ?
ReplyDeleteHey B -
ReplyDeleteI've been able to test Reader DC on both Win 7 and Win 8.1 - pixelation of images within dialogs is happening on both. And if an images has lettering - it's just not useable.
However, tested on a Mac (OS 10.10 Yosemite) with Reader DC and images within a dialog box showed WITHOUT pixelation. So it appears to be working for Mac.
Can't be your code though since it works flawlessly (no image pixelation) in Reader 10 & 11 (Win XP, 7, 8.1) & Reader 10, 11 & DC (Mac OS 10.7 - 10.10)
Problem has to be with Reader DC on Win 7 or 8.1. Maybe it'll work on Acrobat DC? (not the free Reader DC version?)
Talk about disappointing...
B
Hey Bruce:
ReplyDeleteHope you're well! Have a question about loading a value into a dialog if you have a sec?
I have a button (caption is "Type") which triggers a dialog box wherein the end user selects a radio button. When they click "OK" to exit the dialog, their selection changes the caption of the button to match the radio button they selected.
So getting their selection out of the dialog to change the button's caption works fine.
But, should the end user change their mind and click the button again, I can't figure out how to get the caption of the button to switch the corresponding radio button within the dialog to "true."
Built an example available here:
https://www.dropbox.com/s/jd257k78yn4uqev/Radio%20button%20in%20dialog%20changes%20caption%20of%20button%20that%20triggered%20the%20dialog.pdf?dl=0
Any thoughts? Totally stumped. Thanks so much.
Brian
Hey B:
DeleteFigured out the above. Not elegant but it works!
Random follow-up though: dialogs appear to set focus to the first "real" element in the dialog that can be interacted with. (In my example, a radio button is the first object that can be interacted with so it defaults the radio button to "true" even if initialize has it at false.)
Is there a way to set focus to "nothing"(?) when the dialog is generated?
Thanks,
B
Hi Brian,
DeleteGlad you figured it out. I would have put a switch statement after the var d = dialog(); line, so
var d = dialog();
switch (this.resolveNode("Button1.caption.value.#text").value)
{
case "Type":
d.rb00 = true;
break;
case "MCR":
d.rb01 = true;
break;
case "VRC":
d.rb02 = true;
break;
case "RRR":
d.rb03 = true;
break;
case "INS":
d.rb04 = true;
break;
case "DSO":
d.rb05 = true;
break;
case "ODT":
d.rb06 = true;
break;
}
d.execDialog();
Here's my version https://sites.google.com/site/livecycledesignercookbooks/Radio%20button%20in%20dialog%20changes%20caption%20of%20button%20that%20triggered%20the%20dialog.upated.pdf?attredirects=0&d=1.
On mine the OK button gets the default focus, but you can change this by calling dialog.makeDefault("item id"); in the initialise method (where "item id" is the 4 character field id)
Regards
Bruce
Bruce:
ReplyDeleteNice work; yours is way more succinct. Took me 3x longer vs your way. (11 lines vs 30, lol.)
I ended up declaring variables for each radio button value, setting all to "false".
Then a series of if/else if statements exists to change the appropriate variable to "true" if the caption of the button met the condition. Like this:
var rNone = "false";
var ManRetire = "false";
var rVolRetire = "false";
var rReqRepay = "false";
var rIns = "false";
var rDSO = "false";
var rODT = "false";
if (this.resolveNode("type.caption.value.#text").value == "Type"){
var rNone = "true";
}
else if (this.resolveNode("type.caption.value.#text").value == "MCR"){
var rManRetire = "true";
}
else if (this.resolveNode("type.caption.value.#text").value == "VCR"){
var rVolRetire = "true";
}
else if (this.resolveNode("type.caption.value.#text").value == "RRR"){
var rReqRepay = "true";
}
else if (this.resolveNode("type.caption.value.#text").value == "INS"){
var rIns = "true";
}
else if (this.resolveNode("type.caption.value.#text").value == "DSO"){
var rDSO = "true";
}
else if (this.resolveNode("type.caption.value.#text").value == "ODT"){
var rODT = "true";
}
var dialogObject =
{
rb00: rNone,
rb01: rManRetire,
rb02: rVolRetire,
rb03: rReqRepay,
rb04: rIns,
rb05: rDSO,
rb06: rODT,
execDialog: function() { return app.execDialog(dialogDescriptor); },
};
Like I said, I went the long way. Gonna use yours though. Thanks!
Do you have any examples on inserting a variable into the reference of an object?
All of this (the above) is for use in a big table, with most of the cells in the rows having the same name but the individual row names are different.
There's a button to clear a COLUMN of data, but, as I said, I foolishly named the rows individually (i.e.: apple, banana, orange) instead of naming them Row, Row[1], Row[2]. Given the other coding, kinda late to rename now.
So Instead of doing this 28 times in each "clear column" button:
Table1.apple.cell1.rawValue = null'
Table1.banana.cell1.rawValue = null;
Table1.orange.cell1.rawValue = null;
I'd like to create a form level function and use the cell name as a parameter for the function - to the - so I can reuse the function and just change the parameter.
The "wrong" version is something like this:
function clearColumn(txt){
this.resolveNode("page1.Table1.apple." + txt + ".rawValue = null;
this.resolveNode("page1.Table1.banana." + txt + ".rawValue = null;
this.resolveNode("page1.Table1.orange." + txt + ".rawValue = null;
}
Then the function would look something like this in the button:
clearColumn(cell2);
Sure you see what I'm attempting but I'm missing something when inserting a variable into the object reference.
Thanks much again. You saved me about 290 lines with your solution!
B
Hi Brian,
DeleteI'm not sure what is wrong with the expression you have in the resolveNode method, though the closing bracket is missing ... I'm guessing that is just the Blogger comment formatting getting in the way. It should be
this.resolveNode("page1.Table1.apple." + txt + ").rawValue = null;
But you can use a predicate to return all the rows of a table in one go regardless of the name, so a method like this might be closer to what you want.
function clearColumn(table, cell)
{
var rows = table.resolveNodes('#subform.[assist.role == "TR"]');
for (var i = 0; i < rows.length; i++)
{
xfa.host.resetData(rows.item(i).resolveNode(cell).somExpression);
}
}
If this was in a script object called Script and the cell to clear was called TextField1 then you could call it using (assuming your table is called Table1);
Script.clearColumn(Table1, "TextField1");
A table row is really just subform, so the resolveNodes('#subform.[assist.role == "TR"]'); returns all rows that aren't headers (TH) or footers (TF)
Bruce
B -
DeleteI work hard; you work smart. (Trade styles? lol.) Your for statements totally work. Gracias.
But what was wrong with what I wrote initially? Can't I figure out how to insert a variable into an object's reference when using this.resolve node.
Built an example with yours (working) and mine (not working) here: https://www.dropbox.com/s/zfe24p9c85qjbva/BruceWorking.BrianNotWorking.pdf?dl=0
function.clearColumnBrian(cell){
this.resolveNode("page1.Table1.apple." + cell + ").rawValue = null;
this.resolveNode("page1.Table1.banana." + cell + ").rawValue = null;
this.resolveNode("page1.Table1.orange." + cell+ ").rawValue = null;
this.resolveNode("page1.Table1.grape." + cell+ ").rawValue = null;
}
Error message I get is: "Error, Unterminated string constant" - which I get because there are only 3 quotation marks. But where the hell does the fourth go?
Now it's just making me want to punch my monitor.
B
Hi Brain,
DeleteYou don't need that last quotation mark at all, so just
this.resolveNode("page1.Table1.apple." + cell).rawValue = null;
Creating som expressions (or any string) like this can get fiddly, in some cases it can be easier using the util.printf() method. So;
util.printf("page1.Table1.%s.%s", "banana", "cell1")
will produce "page1.Table1.banana.cell1".
This is a little slower, but generally not by enough to be noticed.
Also you need to pass the cell name as a string to the function call in the button click event.
Script.clearColumnBrian("cell2")
Here's a link to the revised form https://sites.google.com/site/livecycledesignercookbooks/home/BruceWorking.BrianWorking.pdf?attredirects=0&d=1
... I hope you monitor is still in one piece ... know the feeling well.
Cheers
Bruce
B -
DeleteFell off the planet for a bit a there but back now. Just saying thanks for the above help, as always.
And a double thanks, actually. Finally got back to work on some things and went a few hours without saving. Not sure how that happened (stupid). Anyway, did a PREVIEW and LC locked up on me. Thought I lost all the work until I found your post here (https://forums.adobe.com/thread/1613090?start=0&tstart=0) and was able to find, open AND IMMEDIATELY SAVE the temp file.
BIG, big thanks, brother.
Best,
Brian
I, ve been playing around with your Dialog.pdf forms to try to build a Dialog for a form i made in LiveCycle. I'm a beginner, but the form works the way i want it to. Using your Dialog.pdf form i tried to generate a Dialog Box. It works fine, but i can't seem to align the boxes i add horizontal (like in your more complex DialogSample). The boxes i add all align vertical. I can move boxes up and down and make them change places, but i want them next to eacht other. How do i do that? Secondly, how do i make the script that is generated work in LIveCycle? DO i just past it in? Do i have to add some other script or "tie" it to a button?
ReplyDeleteHi Mocca,
ReplyDeleteYou can add a View control to the dialog, set the "Align Children" to "Align Row" and then any controls added to the View will be horizontal. A View has it's on Add button or you can move the controls you already have down and they will go into a View control.
If you click the "View Source" button then the dialog code will open in your default .txt file viewer. If this is Notepad then this wont look that great as the line endings are different, but you can still cut and paste into a Designer event and they will come good.
The last lines generated will be something like;
/*var d = dialog();
d.execDialog();
console.println(d.txt1);
console.println(d.txt2);*/
You will need to comment out the first two lines, any input controls in the dialog will have a console.println(..) generated, this is just to see how to get the values back, and can be removed if not needed.
If the user clicks a cancel button then "d.execDialog();" will return "cancel" so you may want to have "var result = d.execDialog();" and then test result for "cancel", but then you might not have a cancel button.
Good Luck
Bruce
HI Bruce,
DeleteThank you for your superfast respons. With your tips i created the Dialogs i needed!! I tried to paste the code in LiveCyle, like so:
1. Add a button to the document or select an existing form field.
2. Display the Script Editor.
3. From the Show pull down, select the click event, or any other event that’s suitable for your purpose.
4. Paste the dialog code into the Script edit area.
But when i clicked the button in the PDF (Acrobat) i didn't get the message / it didn't work. What did i do wrong?
In LiveCyle, in the script is do see the line "//add validate code here" in green. Does this have anything to do with it not working?
The last lines were like you said:
/*var d = dialog();
d.execDialog();
They were in green too.
Since i didn't use a "cancel- button", i removed them. Was that right?
I'm a nitwit trying to make it work ;-). I hope you can help me.
Hi Mocca,
ReplyDeleteSorry to confuse, the lines at the bottom, that is;
var d = dialog();
d.execDialog();
are the ones that display the dialog, in your case you should leave them in but uncomment them.
The "// add validate code here" only needs to change if you need to validate the users input before they click the OK button and close the dialog.
Almost there
Bruce
Hi Bruce,
ReplyDeleteWorked like a charm! Thank you very much! You have no idea what a help you've been in completing my form!
Hey Bruce:
ReplyDeleteHope you're well, amigo. Stuck on something I thought would be relatively simple.
I've got a dialog box using the OK/OTHER/CANCEL button package.
var returnFromBox = d.execDialog; (triggers the dialog just fine)
The following code is able to recognize the return value for OK and CANCEL but not for OTHER
if (returnFromBox == "ok"){
xfa.host.messageBox("apple");
}
else if (returnFromBox == "cancel"){
xfa.host.messageBox("pear");
}
else if (returnFromBox == "other"){
xfa.host.messageBox("grape");
}
What am I missing? Totally stumped....
Thanks,
B
Hi Brian,
ReplyDeleteThe other button click is something you have to handle yourself. So you will need to add something like;
other : function(dialog)
{
dialog.end("other")
}
And in case the code gets mucked up in the comments, here's a sample https://sites.google.com/site/livecycledesignercookbooks/home/ok_cancel_other.pdf?attredirects=0&d=1
Bruce
Hey B -
ReplyDeleteThanks so much for the post. Been trying; still no luck.
Built you an example of what I'm attempting at: https://www.dropbox.com/s/lfvimyaniraigds/ok_cancel_other%20-%20Brian%20to%20Bruce.pdf?dl=0
What I'm trying to accomplish is as follows;
One button with four simple dialogs in them, each giving a hint.
Click the button and Hint 1 opens with "next" and "cancel" button options.
Clicking next would close Hint 1 and open Hint 2; clicking cancel closes Hint 1 and ends the button activity.
Dialogs for hints 2 and 3 would have "previous", "next" and "cancel" buttons.
"Previous" closes current hint and opens previous hint.
"Next" closes current hint and opens next hint.
Think you see where I'm going with this.
I've been trying to use the return value of the dialog to determine what should happen next but it's not really working. Only limited success and only moving forward (using the "ok" button renamed as "next").
Any thoughts would be great. Or should I not be using the return value and using something else?
Thanks a ton, as always.
B
Not sure why that's not working for you. I have updated your sample, in the Hint 2 button you can see the code I suggested.
ReplyDeleteBut now knowing a little more about what you are trying to do, it might be better to have each dialog return which dialog to display next. So there is now a "Bruce's new button" in your sample that does this. Hope it makes sense, I'm passing in the current index to the dialogs and the ok button on all but the last returns the index + 1, cancel returns -1 (that is exit) and other (or previous) returns the index - 1, the ok on the last dialog returns index - 1 ... would have been good if there was a other_cancel control.
https://sites.google.com/site/livecycledesignercookbooks/home/ok_cancel_other%20-%20Bruce%20to%20Brian.pdf?attredirects=0&d=1
Hope that helps.
Bruce
You're amazing, B. Totally helps. Thanks SO much.
ReplyDeleteCouldn't help but try further manipulations out of curiosity- specifically the order of the buttons.
Given "back" is usually to the left and "next" is to the right, I tried moving the code around to match a left to right button order of: OK (now labeled "Previous" )(if visible, to far left), OTHER (now labeled "Next") (in the middle) then "Cancel" (far right) for Hints 2 and 3. Moved functions from Other into OK and OK into Other. ( So "dialogObject.index--;" is now in the far left OK (now labeled Previous) button --- similar to what you did in Hint 4.)
Initial Hint 1 - always appears when main button is clicked; (no surprise; not touching that code).
Hints 2 and 3 - "Cancel" always works. (Again, I'm not touching it.)
"Next" (now the middle "Other" button for Hints 2 and 3) doesn't trigger the closure and reopening BUT it IS doing something as clicking NEXT (despite no visual response) will affect which Hint appears when you then click PREVIOUS (far left; technically the OK button).
Previous (the OK button) always works.
Example here: https://www.dropbox.com/s/9zibfra52svk5qw/ok_cancel_other%20-%20Bruce%20to%20Brian%20-%20Brian%20Messing%20With7.pdf?dl=0
And how'd you disable the little red X in the corner? Or is that because the code at the end is a while statement and the X doesn't return a value for the variable dialogIndex?
Thanks again, as always, Sensei. Truly the best.
B
Hi, you just need to add a dialog.end() to exit the dialog, see the updated sample https://sites.google.com/site/livecycledesignercookbooks/home/ok_cancel_other%20-%20Bruce%20to%20Brian%20-%20Brian%20Messing%20With7a.pdf?attredirects=0&d=1
DeleteBut I'm not sure what you mean by the red X, I still get the standard close dialog X in the top right.
Bruce
Agh..should have realized it. (D*mn it.)
ReplyDeleteAnd sorry for the confusion about the "X." We're talking about the same thing - the box in the upper right of the dialog with the "X" to close the dialog.
Using this method, that X no longer closes the dialog, ie it no longer works as a "cancel". Is that because of the while statement?
B
Hi,
ReplyDeleteMaybe you are better off just using standard buttons and the ok control for cancel?
Here's a sample https://sites.google.com/site/livecycledesignercookbooks/home/ok_cancel_other%20-%20Bruce%20to%20Brian%20-%20Brian%20Messing%20With7b.pdf?attredirects=0&d=1
It is a bit neater. And without the cancel button there is no "X" button in the top right at all ... is that good?
Bruce
Hey B -
ReplyDeleteSick as a dog here - sorry delay. Fill you in more later but the standard button w/ an ok button worked great. Had some formatting issues (my dialogs are wider and taller obviously) but got around it using a gap. And it seems to default to giving the OK button a buffer zone around it - one that it doesn't give to regular buttons - but that actually works great with the layout. Gives a nice subtle separation of the cancel button from the rest of the buttons. Plus no X in the upper right hand corner issue!
Can you recommend any books on dialog creation?
Well done , as always, sir. Much thanks; more laters.
B
Hey B -
ReplyDeleteFeeling better and back on track. But damn you and these dialogs. =)
You did the following to make a button with the item_id of "prev" disappear when the dialog is first created:
initialize : function(dialog)
{
dialog.visible({"prev": false,});
},
I've been able to take it a step further and, by declaring a variable in the click event of the button (var toBold = "123";) make the button appear or disappear based on the value of the toBold variable:
initialize : function(dialog)
{
if (toBold == "123"){
dialog.visible({"prev": false,});
}
},
Assuming you're using the "dialog" font, could something similar be used to set a static text line ("t001")'s "bold" value to true or false on the initialize event? Something like:
initialize : function(dialog)
{
if (toBold == "123"){
dialog.bold ({"t001": false,});
}
},
Know that's not right ("dialog.bold") but I think it gets the point across. Trying to use a variable to change the true/false property of a static text line's bold property.
And do you want to see what I've been working on? Home stretch here - this is actually the last dialog box question. Then just a general clean up of commented-out code -- there's a lot, not surprisingly -- and it's done. Couldn't have done it without you and Cookbooks.
Let me know and deep thanks as always! So close!
B
Hi,
DeleteIf some condition before the dialog is opened determines if the text is bold you can use that condition to set the value of the bold property in the dialog description. So in the sample https://sites.google.com/site/livecycledesignercookbooks/home/DynamicBold.pdf?attredirects=0&d=1 a checkbox determines if the text is bold so the dialog description looks like;
{
type: "static_text",
item_id: "t001",
name: "BOLD",
font: "dialog",
bold: CheckBox1.rawValue == 1,
}
If the condition is something within the dialog then you might be out of luck. The closest I can think of is have two static text objects one bold and one not and make them hidden/visible as needed, but this will leave the space for the hidden text (like invisible for an XFA object).
I don't know of any books of dialogs, apart from the "JavaScript for Acrobat API Reference", but that's got some bits missing, every now and then I come across an example that's using some property I've not seen before, but not for some time now. The ADM dialogs have a lot more functionality than what Acrobat JavaScript has implemented so you never know.
Good to hear you are feeling better, and would be interested in seeing your form. Send me a link here if it is not public, https://forums.adobe.com/people/BR001.
Bruce
Bruce:
ReplyDelete4 hours later. Couldn't crack it. Ugh. Demo page here if you get a sec. Thanks.
https://www.dropbox.com/s/9dlgogfbv0cl08o/Bold%20a%20static%20text%20line%20based%20on%20variable%20value%20-%20Brian%20to%20Brucev2.pdf?dl=0
B
Had to run out without full chance to check. Some success initially with my simple example. Might have issues though as its in the dialogs that we discussed earlier. (the 4 dialogs with PREVIOUS and NEXT buttons.)Will let you know tomorrow...
ReplyDeleteThanks, B.
B
Hi Brian,
ReplyDeleteI've updated the "Bold static text line ..." sample to bold the line selected from the drop down, https://sites.google.com/site/livecycledesignercookbooks/home/Bold%20a%20static%20text%20line%20based%20on%20variable%20value%20-%20Brian%20to%20Brucev2%20(1).pdf?attredirects=0&d=1.
Hope that helps
Bruce
Hey Bruce:
ReplyDeleteBeen a while, amigo. Sent you message via Acrobat Forums. Thought I was done - and I guess I am - but looks like there's one last issue. https://forums.adobe.com/message/8722810#8722810
Other than that, looks like it's ready. Hope you're well. Look forward to hearing from you.
Thanks,
Brian
This comment has been removed by the author.
ReplyDeleteHi Bruce,
ReplyDeleteplease, would you know, how to set the 'max length' of an "edit_text" control on a dialog, so that the user can't enter more then 20 characters?
I know, that I can validate the text later, but that is less appropriate.
Hi Marek,
ReplyDeleteI'm sorry I can't help you with that, I've spent a bit of time trying and I've seen "max-characters" used but it didn't seem to have any affect.
The max length has been implemented in other Adobe software, like Adobe Illustrator plugins so it might be possible. But with a generic JavaScript object it could be called anything.
Please let me know if you work it out.
Bruce
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi Bruce
ReplyDeleteinteresting work! Could you help me out? In a longer form (about 20 pages) we'd like to integrate a slider Control as you presented it in your pdf (as an undocumented Control element). Is it possible to use such a slider element as an object within the Default form, I mean outside a Dialog box? THANK YOU FOR ANY HELP.
Kind regards from switzerland
Urs
Hi Urs,
ReplyDeleteMaybe this sample from Niall would be of interest, his sample has a color picker using a slider for the R, G, B values, http://assuredynamics.com/index.php/2010/11/moving-objects-around-a-form/
I think this will be as close as you can get to using a slider in an XFA form.
Regards
Bruce
Hi Bruce! I am trying to download the samples, but the links are dead. Can you please with that issue?
ReplyDeleteTarek
Hi Tarek, I've fixed the links in the post, seems Google Sites no longer allows attachments. A shame as that is were most of the samples I've posted over the years in the Adobe forums were stored. I don't seem to be able to update the links in the comments part of the blog either, so if there's a particular one you are after from the comments please let me know.
ReplyDeleteRegards, Bruce