Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!oliveb!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Gadgets question Message-ID: <40497@sun.uucp> Date: 29 Jan 88 23:04:50 GMT References: <4830003@hpiacla.HP.COM> Sender: news@sun.uucp Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 51 In article <4830003@hpiacla.HP.COM> jimg@hpiacla.HP.COM (Jim Garrison) writes: >Howdy! > >I am a novice Amiga and 'C' programmer and I've been having this problem >getting Gadgets to work right. I'd really appreciate it if anyone out >there could point me in the right direction. I am also having a problem >with ASDG's FaccII. >Problem #1 -- Gadgets > >I am trying to use Gadgets to request some information in my program and a >couple of the Gadgets I am using need to be Mutually exclusive. Sorry, I can't help with the Facc II problem but Gadgets are something I have played with quite a bit. Basically, mutual exclude does not work for gadgets. It can be made to work fairly simply though, so all is not lost. The technique I use is as follows, in the Gadget structure is a UserData pointer, I point this at other gadgets that are in the same mutual exclude group in a loop so my data structures look like this : +----------+ +----------+ +----------+ +----------+ +-->| Gadget 1 | +-->| Gadget 2 | +-->| Gadget 3 | +-->| Gadget n | | +----------+ | +----------+ | +----------+ | +----------+ | | UserData |--+ | UserData |--+ | UserData |--+ | UserData |--+ | +----------+ +----------+ +----------+ +----------+ | +-----------------------------------------------------------------------+ When you get a IntuiMessage of class GADGETDOWN (or GADGETUP if that is how you are selecting your gadgets) Then you check the UserData pointer to see if it is non-null. If so you loop through looking for the 'other' selected gadget and deselect it. Like so : struct Gadget *TempGad, *CurrentGad; CurrentGad = (struct Gadget *)msg->IAddress; if (!(CurrentGad->UserData)) { for (TempGad = CurrentGad; TempGad != CurrentGad; TempGad = (struct Gadget *)(TempGad->UserData)) if (TempGad->Flags & SELECTED) { TempGad->Flags &= ~SELECTED; RefreshGList(MyWindow,TempGad,1); } } /* Check the parameters to RefreshGList, I don't have an Amiga handy at the moment. */ --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you.