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

App.response and null

Participant ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Why, if the input field is empty and the user pressed the OK button, the function is not interrupted and the Else block is processed?

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

function NumberX() 
{
		Msg = app.response(" ", " ");
		if (Msg == null) {
			app.alert("The user did not enter anything and clicked Ok");
			return;}
		else 
		{	
			app.alert("The user entered some number: " + Msg);
		}			
};

app.trustedFunction(NumberX);

 

TOPICS
Acrobat SDK and JavaScript

Views

74

Likes

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

correct answers 1 Correct answer

LEGEND , Sep 09, 2021 Sep 09, 2021

The documentation says app.response returns null if the user clicks Cancel. Your user is not doing this!

Likes

Translate

Translate
LEGEND ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

The documentation says app.response returns null if the user clicks Cancel. Your user is not doing this!

Likes

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Thank you, now I found it in API 

image.png

Tell me how you can handle the OK button? or for this you need to use app.execDialog ();

Likes

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Just replace null in your code with ""...

Likes

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

I have already tried this option, but then the Cancel button and closing the window with a cross do not work correctly

Likes

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

If they click OK and don't enter anything the returned value is an empty string, which is not the same as null.

Likes

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

You can handle both scenarios at the same time, like this:

 

if (Msg == null || Msg=="")

Likes

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

LATEST

Once again, many thanks!

Likes

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