[comp.sys.amiga.tech] How to deselect a gadget

mjw@f.gp.cs.cmu.edu (Michael Witbrock) (10/06/88)

Thanks for all the replies: 
   The consensus is that the only way to safely have a program unselect a 
   gadget is to REMOVE the gadget, fiddle its bits, and ADD it again.
   
   This is not what I'd call neat. Maybe a general ModifyGadget() in a later 
   release?
   
   In the end, what I did was to make my program do the gadget imagery and keep track of selection status itself.
   
   
   Here is one tricky method suggested by Steve Tibbett:
   
   
   
>   I just ran into the same thing myself.  I don't think there is an official
>   way to deselect a gadget.  BUT due to a bug (or feature?), if you
>   do a refresh on a gadget that is already selected, (with the SELECTED bit
>   still set), it will complement the gadget again - thus deselecting it.
>   
>   So, a seemingly safe way to do it (safe in that if CBM ever fixes it,
>   it will still work) is:  Before fiddling with the SELECTED bits, do a
>   RefreshGList() on your gadgets (which will set everything back to
>   unselected state.

Michael

-- 
Michael.Witbrock@cs.cmu.edu mjw@cs.cmu.edu                          \
US Mail: Michael Witbrock/ Dept of Computer Science                  \
         Carnegie Mellon University/ Pittsburgh PA 15213/ USA        /\
Telephone : (412) 268 3621 [Office]  (412) 441 1724 [Home]          /  \

papa@pollux.usc.edu (Marco Papa) (10/07/88)

In article <3229@pt.cs.cmu.edu> mjw@f.gp.cs.cmu.edu (Michael Witbrock) writes:
|Thanks for all the replies: 
|   The consensus is that the only way to safely have a program unselect a 
|   gadget is to REMOVE the gadget, fiddle its bits, and ADD it again.
|   This is not what I'd call neat. Maybe a general ModifyGadget() in a later 
|   release?

Not needed, it is all documented (see later).

|   In the end, what I did was to make my program do the gadget imagery and keep track of selection status itself.
|   Here is one tricky method suggested by Steve Tibbett:
|   
||   I just ran into the same thing myself.  I don't think there is an official
||   way to deselect a gadget.  

Yes, there is.

||BUT due to a bug (or feature?), if you
||   do a refresh on a gadget that is already selected, (with the SELECTED bit
||   still set), it will complement the gadget again - thus deselecting it.
||   So, a seemingly safe way to do it (safe in that if CBM ever fixes it,
||   it will still work) is:  Before fiddling with the SELECTED bits, do a
||   RefreshGList() on your gadgets (which will set everything back to
||   unselected state.

Nope, don't do indoiscriminate RefreshGlists: the "CBM-recommended" way 
to "fiddle" with gadgets is:

1. RemoveGadget
2. fiddle with gadgets imagery, SELECTED, text, etc...
3. RefreshGadgets or RefreshGList

Also (and this is documented twice in the 1.2 Enhancer docs) these games
(especially the SLECTED toggle) can be played safely ONLY with gadget
with imagery, not with simple boolean gadgets.  This is not a bug.
this is just the way things are and have been (the 1.2 Enhancer docs
is almost two years old).

-- Marco Papa 'Doc'
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
uucp:...!pollux!papa       BIX:papa       ARPAnet:pollux!papa@oberon.usc.edu
 "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

jesup@cbmvax.UUCP (Randell Jesup) (10/08/88)

In article <12623@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes:
>In article <3229@pt.cs.cmu.edu> mjw@f.gp.cs.cmu.edu (Michael Witbrock) writes:
>|Thanks for all the replies: 
>|   The consensus is that the only way to safely have a program unselect a 
>|   gadget is to REMOVE the gadget, fiddle its bits, and ADD it again.
>|   This is not what I'd call neat. Maybe a general ModifyGadget() in a later 
>|   release?
...
>1. RemoveGadget
>2. fiddle with gadgets imagery, SELECTED, text, etc...

 2.5 AddGadget or AddGList it back

>3. RefreshGadgets or RefreshGList
>
>Also (and this is documented twice in the 1.2 Enhancer docs) these games
>(especially the SLECTED toggle) can be played safely ONLY with gadget
>with imagery, not with simple boolean gadgets.  This is not a bug.
>this is just the way things are and have been (the 1.2 Enhancer docs
>is almost two years old).

	Yup.  There are some tricks that work to do this to non-image
gadgets, but they are not in any manner guaranteed or sanctioned, and may
well break in 1.4 (being dependant on Intuitions internal State Machine).

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (10/11/88)

In article <12623@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes:
>Nope, don't do indoiscriminate RefreshGlists: the "CBM-recommended" way 
>to "fiddle" with gadgets is:
>
>1. RemoveGadget
>2. fiddle with gadgets imagery, SELECTED, text, etc...
>3. RefreshGadgets or RefreshGList
>
	However, you are still screwed if you are dealing with gadgets that
have only GadgetText linked to them.  This is probably due to the sequence
in which Intuition renders the Gadget imagery.

	The reason this approach works with Image gadgets is because Images
are rather like bitmaps, and thus blitz over the previous imagery
(highlighted or not).

	However, the use of an Image in a Gadget deprives you of the
ability to put a Border around your gadget, unless you make it part of the
image.

>Also (and this is documented twice in the 1.2 Enhancer docs) these games
>(especially the SLECTED toggle) can be played safely ONLY with gadget
>with imagery, not with simple boolean gadgets.  This is not a bug.
>this is just the way things are and have been (the 1.2 Enhancer docs
>is almost two years old).
>
	This is *too* a bug (my opinion, my opinion).  The fact that it has
existed forever doesn't make it any less irritating.

	Too bad the Gadget's MutualExclude field is still unused; this
problem wouldn't exist otherwise.  Sigh.

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
 \_ -_		Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor