InputRequester - How do I distinguish between "Cancel" and entering an empty string?

Just starting out? Need help? Post your questions and find answers here.
Lebostein
Addict
Addict
Posts: 841
Joined: Fri Jun 11, 2004 7:07 am

InputRequester - How do I distinguish between "Cancel" and entering an empty string?

Post by Lebostein »

Is it impossible?
User avatar
mk-soft
Always Here
Always Here
Posts: 6331
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: InputRequester - How do I distinguish between "Cancel" and entering an empty string?

Post by mk-soft »

With default string ?!

Code: Select all


Value.s = "Default"
s1.s = InputRequester("Input", "Text", Value)

If s1 = Value
  Debug "Not Change"
ElseIf S1 = ""
  Debug "Empty"
Else
  Debug "Input: " + s1
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
BarryG
Addict
Addict
Posts: 4225
Joined: Thu Apr 18, 2019 8:17 am

Re: InputRequester - How do I distinguish between "Cancel" and entering an empty string?

Post by BarryG »

Depends on your needs. In my app, the user can hit Esc to cancel the prompt; or enter some new text for it; or select and delete the existing default text to indicate that no text should be used. You can't use InputRequester() to distinguish between all three cases, so I needed to roll my own solution.
Quin
Addict
Addict
Posts: 1148
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: InputRequester - How do I distinguish between "Cancel" and entering an empty string?

Post by Quin »

mk-soft wrote: Thu Nov 30, 2023 10:43 am With default string ?!

Code: Select all


Value.s = "Default"
s1.s = InputRequester("Input", "Text", Value)

If s1 = Value
  Debug "Not Change"
ElseIf S1 = ""
  Debug "Empty"
Else
  Debug "Input: " + s1
EndIf
Only problem with this approach is that the text isn't selected by default, so I have to explicitly select all and delete "default" before I can type what I want.
Post Reply