FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`InputBox`: cancel vs empty string · Issue #390 · ClearFoundry/ClearScript · GitHub

InputBox: cancel vs empty string #390

Description

Is there any way, for an InputBox, to differentiate between the user clicking the Cancel button and the user clicking OK and the text box being an empty string being?

As far as I can tell, as it currently stands, both actions produce the same object of type Microsoft.ClearScript.Undefined.

Sample code in C#:

var obj = engine.Evaluate("InputBox(\"Type here:\", \"" + dialog_title + "\", \"\")");
if (obj is Microsoft.ClearScript.Undefined)
{
    Console.WriteLine(":(");
}

I have the following code in C which correctly detects the user pressing Cancel vs pressing Ok with an empty text field:

VARIANT result;
VariantInit(&result);
pActiveScriptParse->lpVtbl->ParseScriptText(pActiveScriptParse, wszEvaluation2, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &result, &ei);
BOOL bWasCancelled = (result.vt == VT_EMPTY);
// else, the field's content was empty or not, it is stored in result.bstrVal

I don't know exactly how this thing is implemented here internally, but a differentiation has to be made between when the VARIANT returned by ParseScriptText is VT_EMPTY, or when it contains a BSTR string that is empty, aka "".

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL