realbasic-nug
[Top] [All Lists]

Re: Enabling the OK Button on the Fly

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Enabling the OK Button on the Fly
From: Charles Yeomans <yeomans at desuetude dot com>
Date: Sun, 3 Oct 2004 18:39:08 -0400
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <p06110400bd8624ed231b at [131 dot 158 dot 15 dot 85]>

On Oct 3, 2004, at 6:11 PM, Charles Kelley wrote:

Hi, all!

I have designed a very long form in a dialog box for a membership database I'm developing. It consists of editfields for first name, middle name, last name, street address, city, state, ZIP (postal) code; various roles in the organization and various means of contact; popup menus for age group and affiliation type.*

The OK button should be disabled when all of the editfields are empty, all of the checkboxes are unchecked, and all of the popup menus are UNKNOWN; that is, when the form is blank, in layman's terms. That's easy when the form first appears: nothing is filled in, so the OK button begins disabled.

But a problem arises when the form is filled in because a field could be filled in and then cleared a short time later. The OK button ought to be disabled or enabled accordingly. In short, I'm trying to do this [in pseudocode]

                if dialogBox.FormBlank then
                        OKButton.enabled = FALSE
                else
                        OKButton.enabled = TRUE
                end if // is the form blank?

How do I achieve that? When I first began developing it in a THINK Pascal program a decade ago, I put the check in the idle event. But I don't see an event analogous in RB. Can anyone suggest where to put the check?

I suppose that you could simulate such an event by dropping a Timer on the window. In the Timer's Action event, set the Pushbutton state. I generally avoid this sort of approach if possible.

An alternative would be to set the Pushbutton state using essentially the code of the Timer.Action event whenever a control changes state; that is, in the TextChange event of EditFields, the Change event of PopupMenus, etc.

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>