Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofSystemTextBoxDialog: Capturing "Cancel" with pre-populated values #4945

Closed
sqrtof5 opened this issue Feb 24, 2016 · 1 comment
Closed

ofSystemTextBoxDialog: Capturing "Cancel" with pre-populated values #4945

sqrtof5 opened this issue Feb 24, 2016 · 1 comment
Assignees
Milestone

Comments

@sqrtof5
Copy link

sqrtof5 commented Feb 24, 2016

When using ofSystemTextBoxDialog with a pre-populated input field, there is no way to know that the "Cancel" option has been chosen if the pre-populated value is a valid answer.

Typical use is something like:

string userInputText = ofSystemTextBoxDialog("Question?", "Pre-populated valid answer, not identifiable placeholder");
//check userInputText value

The issue is that in this simple case, userInputText will hold the pre-populated answer even if Cancel is selected (by implementation in ofSystemUtils.cpp).

I wonder if that could be addressed, maybe by returning an empty string?
E.g. (OSX):

text = ( returnCode == NSAlertFirstButtonReturn ) ? [[label stringValue] UTF8String] : "";

Or maybe there's another way to handle these (admittedly edge) cases?

@ofTheo ofTheo self-assigned this Feb 24, 2016
@ofTheo ofTheo added this to the 0.10.0 milestone Feb 24, 2016
@ofTheo
Copy link
Member

ofTheo commented Feb 24, 2016

The empty string approach seems like a good way.
It should probably only be the repopulated text if the person hits the okay button.

We could also switch the return type to a custom type which contains the string and also the button that was hit, but this might be an overly complex way to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants