Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Gadget ID codes? Message-ID: <31230@sun.uucp> Date: Mon, 19-Oct-87 13:37:26 EDT Article-I.D.: sun.31230 Posted: Mon Oct 19 13:37:26 1987 Date-Received: Tue, 20-Oct-87 20:46:57 EDT References: Sender: news@sun.uucp Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 57 In article (Michael Portuesi) writes: >I want to present a requester in the current window with a string >gadget for user input and two boolean gadgets for "OK" and "Cancel." >If the user selects "Cancel", obviously I don't want to do anything. >What is the correct way to determine what gadget the user activated >to end the requester? I set the GadgetID field of each of my gadget >definitions to a unique value. I throw the requester up on the >screen, wait for an IDCMP message, extract the code from the message >structure, then reply to it. My assumption is that the message code >would contain the ID of the selected gadget that caused the requester >to end, although the Intuition manual doesn't really tell you what it >should contain. Is my assumption correct? Yes, it is correct. When you put up a requester, assuming it does not have the NOISY flag set, then all of the IDCMP events you will receive come from that requester. If you have gadgets in the requester your loop looks something like : (Note, this is from memory so some structure fields may be wrong) done = FALSE; do { Wait(mywindow->UserPort->mpSigBit); im = (struct IntuiMessage *)GetMsg(mywindow->UserPort); if (im == NULL) continue; class = im->Class; address = im->Iadress; x = im->MouseX; y = im->MouseY; ReplyMsg(im); switch (classe) { case GADGETUP : case GADGETDOWN : g = (struct Gadget *)address; done = ((g->GadgetFlags & ENDGADGET) != 0); id = g->GadgetID; switch (id) { case CANCELID : /* cancel here */; case OKID : /* process data here */; etc; } break; default : break; } } while (! done); Which will loop around until a gadget with the ENDGADGET flag is clicked upon. In the meantime clicking on other gadgets will be processed by this loop. Note that if you have NOISYREQ set you can also watch for VANILLAKEY events and let the user press 'O' or 'C' to mean OK or CANCEL on the requester. Anyway, when the message is received, if it is a gadget message then the iaddress field contains a pointer to the gadget struct that was clicked upon. You can proabably take it from their. --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.