[comp.sys.amiga.programmer] Boolean Gadget Mutual Exclusion?

smithey@esosun.UUCP (Brian Smithey) (02/01/91)

I want to create a set of "radio buttons", where only 0 or 1
button of the set is selected at any one time.  I figured
to do this with TOGGLESELECT boolean gadgets, and when I get
a selection I'd traverse my list of radio-button gadgets,
and remove the SELECTED flag if one of the gadgets were already
selected.  I'd also prefer to use RELVERIFY with these boolean
gadgets.

My question concerns the section on Mutual Exclusion of gadgets
in the 1.3 Libs+Devs RKM.  The RKM says that you must use
hit-select rather than toggle-select, and GADGIMMEDIATE
rather than RELVERIFY when doing mutual exclusion with
boolean gadgets.  However, earlier they talk about "turning
off" excluded gadgets; I'm never turning any of these gadgets
off (assuming this means the GADGDISABLE flag or OffGadget()),
just modifying the SELECTED state (and refreshing).  Is my
radio-button scenario described above considered "mutual
exclusion" as discussed in the RKM?  Is my plan ok, or am I
asking for trouble?  I'm new at this, so all help is appreciated,
and pointers to other sections in the RKM's are welcome.

Thanks,

Brian

-- 
Brian Smithey / SAIC, Geophysics Division / San Diego CA
uucp:	   uunet!seismo!esosun!smithey
Internet:  smithey@esosun.css.gov

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (02/02/91)

In article <659@esosun.UUCP> smithey@esosun.css.gov.UUCP (Brian Smithey) writes:
>I want to create a set of "radio buttons"...with TOGGLESELECT gadgets...
>...I'd traverse my list of radio-button gadgets, and remove the SELECTED
>flag if one of the gadgets were already selected.  I'd also prefer to
>use RELVERIFY with these boolean gadgets.

Sounds like you're on the right track, just be sure that you remove
the gadgets (RemoveGadget() or RemoveGList()) before modifying it.
When you are done changing the gadget, you can add it back and
refresh it to update the display.

>The RKM says that you must use
>hit-select rather than toggle-select, and GADGIMMEDIATE
>rather than RELVERIFY when doing mutual exclusion with
>boolean gadgets.

Mutual exclude gadgets are not supported through Intuition, you have to
use Gadtools or roll your own.  If you create your own, then you can
make up the rules as you go along.  The RKM shows one way to implement
this function.  If you want a different functionality to your gadgets,
feel free to do so.

The wording in the RKMs is a bit strong, clearly (as long as you follow
the rules) you can use any technique you want to get the desired result.
The "code police" will not come to get you if you use another technique.

>However, earlier they talk about "turning
>off" excluded gadgets; I'm never turning any of these gadgets
>off (assuming this means the GADGDISABLE flag or OffGadget()),
>just modifying the SELECTED state (and refreshing)...

Again, you don't need to "turn off" the gadgets, you need to remove them
from the gadget list before you modify them.  Modifying gadget structures
without removing them is illegal.
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (02/02/91)

In article <18431@cbmvax.commodore.com> ken@cbmvax.commodore.com (Ken Farinsky - CATS) writes:
>>The RKM says that you must use
>>hit-select rather than toggle-select, and GADGIMMEDIATE
>>rather than RELVERIFY when doing mutual exclusion with
>>boolean gadgets.
>
>Mutual exclude gadgets are not supported through Intuition, you have to
>use Gadtools or roll your own.  If you create your own, then you can
>make up the rules as you go along.  The RKM shows one way to implement
>this function.  If you want a different functionality to your gadgets,
>feel free to do so.
>
>The wording in the RKMs is a bit strong, clearly (as long as you follow
>the rules) you can use any technique you want to get the desired result.
>The "code police" will not come to get you if you use another technique.

Ok, I have now talked to the new "Intuition Guru" (Peter Cherna), who
informs me that my answer was not quite correct.  Peter, jump right in
if I miss anything here.

GADGIMMEDIATE is specified as "required" due to problems with removing
gadgets.  When you create mutual exclude gadgets, your code has to spend
a lot of time removing the gadgets, updating the state and refreshing
the display.  The problem is, under 1.3 at least, removing an active
gadget can cause problems with intuition.  If you use RELVERIFY, then
the user can "hold down" the gadget, leaving it active for an extended
period of time.  This might be a problem if the user clicks on the gadget
twice quickly, holding it down the second time.  In this case, the code
might try to remove the gadget (acting on the first message) while the
gadget is active (the user is still holding it down.)  Using GADGIMMEDIATE
solves this problem, as the gadget does not have the extended active
period.

We could not come up with a definitive answer as to why hit-select
gadgets were important, and it may be possible to create the behavior
you want using toggle-select gadgets.  Hit-select gadgets turn out
to be simpler to use, as you know their state after they have been
selected.  You can probably create the desired actions by slightly
modifying the recommended model, rather than trying to re-invent the
wheel.  If you follow the information in the RKMs, you will minimize the
time you spend solving problems that have been encountered in the past.

A lot of expertise has gone into the RKMs.  We'll try to do a better
job of documenting the reasoning behind the information in the next
set.  No, I do not have any information on the timing or the price
of the next set of RKMs, but we are always working to improve the
support we provide to developers.
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky