Subject Re: radio button
From Mervyn Bick <invalid@invalid.invalid>
Date Fri, 17 Jul 2020 12:28:45 +0200
Newsgroups dbase.getting-started

On 2020-07-14 21:58, Ronnie MacGregor wrote:
> In article <KWmwlIeWWHA.1756@ip-AC1E04A7>, akshat.kapoor@kapoorsons.in
> says...
>
>> unable to prevent double firing of onChange
>> event
>
> But of course it is a simple matter to prevent the onChange code from
> executing twice within a given time frame . . . .
>
>

The actual problem is not preventing the code in the onChange event
handler from being executed.

The problem is that the program needs to know exactly which radiobutton
was selected previously so that that specific radiobutton (which could
be any radiobutton in the group) can be re-selected if the used cancels
the execution of the code.  The next snag is that re-selecting the
original radiobutton to put things back as they were must not trigger
any code.

I have created a custom radiobutton which registers each radiobutton in
an assocArray on the form together with it's value.  This is kept up to
date as a radiobutton is selected.  By using the CALLBACK command one
can monitor mouse clicks before dBASE has a chance to react to them.
This means that when the user clicks on a different radiobutton the
program has the opportunity to scan the assocArray and determine which
radiobutton in the group was last set on before dBASE sets the clicked
radiobutton's value true.

Once the identity of the radiobutton that was on originally is known the
rest becomes fairly straightforward housekeeping.

As the custom control uses the CALLBACK command it can only be used with
dBASE Plus 8 and later.  As it stands the control can only be used in
one group of radiobuttons.

Mervyn.