Find out user has pressed OK or Cancel in JavaScript dialog

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Find out user has pressed OK or Cancel in JavaScript dialog

Postby tashimaya » Sun Dec 14, 2014 2:19 pm

I'm using cefclient on Windows 7.

I'm returning false from OnBeforeUnloadDialog() to use the default dialog implementation.

Is there any way to find out if the user has pressed "OK" or "Cancel" in the JavaScript Confirm dialog?

Many thanks
tashimaya
Techie
 
Posts: 36
Joined: Fri Oct 10, 2014 7:18 am

Re: Find out user has pressed OK or Cancel in JavaScript dia

Postby magreenblatt » Mon Dec 15, 2014 5:49 am

Yes, check the return value in JavaScript.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Find out user has pressed OK or Cancel in JavaScript dia

Postby tashimaya » Mon Dec 15, 2014 6:45 am

Thank you for your reply magreenblatt.

RE: CefJSDialogCallback's void Continue( bool success, const CefString& user_input )

The |user_input| value should be specified for prompt dialogs.

I'm not entirely sure what I'm supposed to pass for user_input.

So for example if I were using my custom dialog with "OK" and "Cancel", should I do something like this?

Code: Select all
var dialogResult = MessageBox.Show(messageText, "Confirm Navigation", MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.OK)
   callback.Continue(true, "OK");
else
   callback.Continue(false, "Cancel");


Thanks again
tashimaya
Techie
 
Posts: 36
Joined: Fri Oct 10, 2014 7:18 am

Re: Find out user has pressed OK or Cancel in JavaScript dia

Postby magreenblatt » Mon Dec 15, 2014 7:01 am

The |user_input| argument is only used for prompt dialogs where the user enters text. It can be empty for confirm dialogs.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 33 guests