[comp.sys.amiga.tech] three-state gadget

840445m@aucs.uucp (Alan McKay) (01/20/90)

I am working on a program that requires a three state gadget, similar to
a boolean gadget but only with three states.  I've devised a method but am
having trouble getting it to work.  First I'll tell you what I want and then
I'll tell you how I am doing it and what is wrong.

Consider (for example) two gadgets in a window.  The first one allows you 
to select an action, say open, save, delete.  The second gadget is a simple
boolean gadget labelled "engage" which when pressed will begin the action as
shown on the first gadget.  Thus, each time gadget 1 is pressed the word
on it will change from "open" to "save" to "delete" and so forth moduloly.

Here is what I am doing.  I use a simple boolean gadget for number one.   
Instead of the regular IntuiText structure for the gadget I have an array of
3 texts; one for "open", "save" and "delete" respectively.  The "UserInfo"
field of the gadget points to an integer which keeps track of which function
is currently being displayed (and thus which IntuiText to use).  Whenever the
gadget is pressed I simply (or so I thought) remove it from the list, change
the IntuiText field to point to the new text (and update the integer which
keeps track of this), put the gadget back into the list, and then refresh
the gadget list.  Sounds simple to me, but it does not work.  At first it
would superimpose "save" onto "delete" and so on, making it look as though
it were almost working.  But it would only work the once.  The gadget would
only highlight once (indicating being pressed i.e. GADGHCOMP) then would
do nothing after being pressed again.  This is my first real attempt to
do anything with gadgets so I am not really sure of what I do.  Here is
the code:

	gadpos = RemoveGadget( wind, gadg );
	gadg->GadgetText = &itext[(int)(gadg->UserData =                 
					(int)gadg->UserData++%3)];
	gadpos = AddGadget( glist, gadg, gadpos );
	RefreshGList( gadg, wind, NULL, 1 );

Any ideas what I am doing wrong?  Or conversely, what is a better way to
implement such a gadget?      

When this code was "sortof" working, it appeared that my refresh was not
getting rid of the old text that was there, how can I get rid of the old
stShould I being using an image rather than IntuiText for my gadget
display?

I just realised now that what I want is exactly like what you see in a file
requester.  The button for "drive" which changes to the name of each drive
each time you hit it.  How is this done?  Can anyone send me or point me
to some sample code?

Thanks in advance.
-- 
+ Alan W. McKay       +  VOICE: (902) 542-1565                        +
+ Acadia University   +  "Courage my friend, it is not yet too late   +
+ WOLFVILLE, N.S.     +   to make the world a better place."          +
+ 840445m@AcadiaU.CA  +                    - Tommy Douglas            +

johnl@tw-rnd.SanDiego.NCR.COM (John Lindwall) (01/23/90)

In article <1990Jan20.001453.4445@aucs.uucp> 840445m@aucs.UUCP (Alan McKay) writes:
>                                                              At first it
>would superimpose "save" onto "delete" and so on, making it look as though
>it were almost working. 

This super-imposing problem sounds a problem I had when playing with MenuItems
(which also use Intuitext structs).  Make sure you are using JAM2 for the 
DrawMode and the new text should wipe out the old (if they are of the same
length).  Either that or somehow erase it yourself.  I can't help with the
real meat of the problem, though.  Good luck.

-- 
John Lindwall                     |   "Not my employer opinions; mine"
johnl@tw-rnd.SanDiego.NCR.COM     |   a man, a plan, a beer, reeban alpa nama
----------------------------------+--------------------------------------------