• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dialogue window is always in focus

Participant ,
Oct 06, 2021 Oct 06, 2021

Copy link to clipboard

Copied

How to change the code so that when the button is pressed, the dialog window does not close, and it would be possible to re-enter the data in the edittext and click the button again?

app.addMenuItem({ cParent:"Help", cName:"-", cExec:" ", nPos: 0});
app.addMenuItem({ cParent: "Help", cUser: "Test", cName: "Test", cExec: "Test()", cEnable: "event.rc = (event.target != null);",  nPos: 0});

function Test() 
{
var dialog1 = 
{
	Btn1: function(dialog)
	{
		var result = dialog.store()["Txt1"]
		Ndata = result
		dialog.end("Btn1");
	},
	Stop: function(dialog)
	{	
		idx = "Cancel"
		dialog.end("Stop");
	},
	description:
	{name: "Test", align_children: "row", width: 300, height: 300,
		elements:
		[
			{
				alignment: "align_right",
				type: "button",
				name: "Cancel",
				item_id: "Stop",
				width: 5
			},
			{
				type: "edit_text",
				item_id: "Txt1",
				width: 170,
				height: 25
			},
			{
				type: "button",
				name: "Enter date",
				item_id: "Btn1",
			}
		]
	}
};
app.execDialog(dialog1);

		array = this.getPageBox("Crop",1);
		r = array.toString()
		r = r.split(",");
		rectX1 = [Math.round(r[2])-391, 108, Math.round(r[2])-354, 132];
		this.addAnnot({page: 1, type: "Stamp", rect: rectX1, author: "", AP: "#NewDate" })

}; app.trustedFunction(Test);

 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

389

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2021 Oct 06, 2021

Copy link to clipboard

Copied

Dialogs in Acrobat are modal. You can't leave interact with the rest of the application while they are open.
What you can do, though, is re-open the dialog after it closed. You would need to re-populate all the fields in it with the old values entered into them, though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2021 Oct 06, 2021

Copy link to clipboard

Copied

Suppose the old data does not need to be filled in again, what would the code look like then? I tried to duplicate the Dialog call, but nothing works.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2021 Oct 06, 2021

Copy link to clipboard

Copied

Yes, that should have worked... Can you post your code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 07, 2021 Oct 07, 2021

Copy link to clipboard

Copied

I am sorry, I had a mistake in the code, the Dialog window does appear again, but only once.

app.addMenuItem({ cParent:"Help", cName:"-", cExec:" ", nPos: 0});
app.addMenuItem({ cParent: "Help", cUser: "Test", cName: "Test", cExec: "Test()", cEnable: "event.rc = (event.target != null);",  nPos: 0});

function Test() 
{
var dialog1 = 
{
	Btn1: function(dialog)
	{
		var result = dialog.store()["Txt1"]
		Ndata = result
		dialog.end("Btn1");
	},
	Stop: function(dialog)
	{	
		idx = "Cancel"
		dialog.end("Stop");
	},
	description:
	{name: "Test", align_children: "row", width: 300, height: 300,
		elements:
		[
			{
				alignment: "align_right",
				type: "button",
				name: "Cancel",
				item_id: "Stop",
				width: 5
			},
			{
				type: "edit_text",
				item_id: "Txt1",
				width: 170,
				height: 25
			},
			{
				type: "button",
				name: "Enter date",
				item_id: "Btn1",
			}
		]
	}
};
app.execDialog(dialog1);

		array = this.getPageBox("Crop",1);
		r = array.toString()
		r = r.split(",");
		rectX1 = [Math.round(r[2])-391, 108, Math.round(r[2])-354, 132];
		this.addAnnot({page: 1, type: "Stamp", rect: rectX1, author: "", AP: "#NewDate" })
var dialog1 = 
{
	Btn1: function(dialog)
	{
		var result = dialog.store()["Txt1"]
		Ndata = result
		dialog.end("Btn1");
	},
	Stop: function(dialog)
	{	
		idx = "Cancel"
		dialog.end("Stop");
	},
	description:
	{name: "Test", align_children: "row", width: 300, height: 300,
		elements:
		[
			{
				alignment: "align_right",
				type: "button",
				name: "Cancel",
				item_id: "Stop",
				width: 5
			},
			{
				type: "edit_text",
				item_id: "Txt1",
				width: 170,
				height: 25
			},
			{
				type: "button",
				name: "Enter date",
				item_id: "Btn1",
			}
		]
	}
};
app.execDialog(dialog1);
}; app.trustedFunction(Test);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2021 Oct 07, 2021

Copy link to clipboard

Copied

- You don't need to re-define the dialog. You can use the original variable you created for it.

- If you don't want the dialog to close put it in a loop, but make sure to define a stop condition or you'll be stuck in it and will have to hard-close the application!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2021 Oct 07, 2021

Copy link to clipboard

Copied

PS. There are much easier and better ways of doing what you're trying to do. For example, you can use the validate function of the dialog to prevent it from closing in the first place if the user didn't fill in a required field.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 07, 2021 Oct 07, 2021

Copy link to clipboard

Copied

do not quite understand how it is possible to do this? can you show at least schematically? By loop you mean let's say the operator While? Pressing the Cancel button can be made a condition for exiting the loop?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2021 Oct 07, 2021

Copy link to clipboard

Copied

Here you go:

 

var userDate = null;
var dialog1 = 
{
	validate: function(dialog) {
		var v = dialog.store()["Txt1"];
		if (v=="") {
			app.alert("You must enter a date.");
			return false;
		}
		return true;
	},
	
	commit: function(dialog) {
		userDate = dialog.store()["Txt1"];
	},
	
	description:
	{name: "Test", align_children: "row", width: 300, height: 300,
		elements:
		[
			{
				type: "edit_text",
				item_id: "Txt1",
				width: 170,
				height: 25
			},
			{
				type: "ok_cancel",
				ok_name: "Enter Date",
				cancel_name: "Cancel"
			}
		]
	}
};
if (app.execDialog(dialog1)=="ok") app.alert("You entered " + userDate);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 07, 2021 Oct 07, 2021

Copy link to clipboard

Copied

LATEST

Your option does not fit, i meant something like this:

...
var retn = app.execDialog(dialog1);
if (retn != "Stop") {retn};

but this code doesn't work yet either, Dialog disappears after the second button press(

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines