Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!psuvax1!rutgers!netnews.upenn.edu!cps3xx!griffin From: griffin@frith.egr.msu.edu Newsgroups: comp.sys.amiga.tech Subject: software selecting string gadgets Message-ID: <6425@cps3xx.UUCP> Date: 12 Feb 90 20:44:35 GMT Sender: usenet@cps3xx.UUCP Reply-To: griffin@frith.egr.msu.edu () Organization: Michigan State University, College of Engineering Lines: 57 In message <575@galadriel.bt.co.uk> Steve Paine writes: >SCENARIO: > Five string Gadgets set up on a window. >PROBLEM: > Want to be able to cycle through them one at a time, putting strings > in them and going on to the next one when I press return. [stuff deleted...] > How do I, by software, select a string gadget so that I can > type in data as if I had selected it with the mouse? Add this code to your event processing function... ULONG class; APTR address; struct IntuiMessage *message; while(message = GetMessage(window->UserPort)) { class = message->Class; address = (struct Gadget *)message->IAddress; /* addr of selected gadget */ ReplyMsg(message); switch(class) { case GADGETUP: return(dogadget(address->GadgetID)); break; } } Then, your gadget processing function could be something like... dogadget(gadnum) USHORT gadnum; { switch(gadnum) { case 1: ActivateGadget(&Gadget2, window, NULL); break; case 2: ActivateGadget(&Gadget3, window, NULL); break; case 3: ActivateGadget(&Gadget4, window, NULL); break; case 4: ActivateGadget(&Gadget5, window, NULL); break; case 5: return(1); break; } return(0); } Now what you need to do is define the next-to-the-last field in your struct Gadget definition. This is a user definable field - the ordinal gadget number. This is the gadget's 'address'. I used a 1 for Gadget1. This will step through your gadgets with the return key. If you click on a gadget, the return key will continue on from there. It is up to you to do something with the info in the string gadgets, of course. Using returns as I did will return a value to the original calling function. It can use this value to determine what to do next (continue processing records, etc. - e.g. a '1' means that the user has finished with string gadget #5). Excuse my non-ANSI calls here. ;^) Dan Griffin griffin@frith.egr.msu.edu "We're waiting for Godot..."