How to tell if a field is "closed"?
mark at livecode.com
Tue Feb 5 14:53:41 EST 2019
On 2019-02-05 20:25, Paul Dupuis via use-livecode wrote:
> I have a problem for which I should probably redesign the user
> interface, but would rather not do so for many reasons.
> The problem is this:
> 1) There are some fields on a card. Each field has a "closeField"
> handler that checks the fields content for validity and presents
> appropriate error messages (via a standard 'answer" command).
> 2) There is an "Import" button that collects the field values and lots
> of other data and does a task in my application.
> 3) If a user edits a fields and enters an invalid value and does not
> click, tab, or press the return key to "close" the field and trigger
> the "closeField" message, but immediately clicks on the "import"
> button, my import script starts using the invalid value from the open
> field while at the same time a closeField message does get send and an
> answer dialog appears telling what is invalid about the entry.
> However, I am wondering if anyone in the LiveCode brain trust has
> figured out a better way to handle something like this?
How about this...
In your closeField handlers, if the field fails validation do:
if <not validated> then
answer "Field failed validation" with "Oops - I'll correct it" or
if it is "Cancel" then
exit to top
focus on me
Then in your import button do:
focus on nothing
if the selectedField is not empty then
This should mean the import step won't run until a closeField handler
has successfully finished.
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the Use-livecode