Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!rutgers!cbmvax!peter From: peter@cbmvax.commodore.com (Peter Cherna) Newsgroups: comp.sys.amiga.tech Subject: Re: Some Gadget Questions? Message-ID: <9647@cbmvax.commodore.com> Date: 12 Feb 90 21:03:14 GMT References: <1075@mindlink.UUCP> <1990Feb10.221204.9516@csusac.csus.edu> Reply-To: peter@cbmvax.cbm.commodore.com (Peter Cherna) Organization: Commodore, West Chester, PA Lines: 90 In article <1990Feb10.221204.9516@csusac.csus.edu> cs03513@athena.UUCP (Jerry Garcia) writes: > > > I have a couple of questions about gadgets. First I am using power >windows. The program that I am working on has a custom screen, and two >borderless windows. Each window has several gadgets. I am using Lattice >c. The first question That I have has to do with boolean gadgets and the >necessary flags. I started by creating the first window with several >string gadgets and one boolean gadget. When the boolean gadget was >selected I wanted to save the info and close the window. I accomplished >this by setting the following IDCMP flags, GadgComp, Relverfiy, ^^^^^^^^ ^^^^^^^^^ >GadgImmediate. By using the source debugger(CPR) I found that selecting ^^^^^^^^^^^^^ >these flags caused a message to be sent to the message port with the value >of 32. Now I created a second window with several string and one boolean >gadget. The boolean gadget was set up the same way. I open the second >window first but when I select the boolean gadget nothing goes to the >message port. What I need to know is how to get a message to the message >port so I can deal with this event. First, be careful not to confuse flags of different purpose. The IDCMP flags that relate to gadgets are GADGETUP and GADGETDOWN (MOUSEMOVE can also be useful). Gadgets themselves have two flags fields, "Flags", and "Activation". GADGHCOMP is a value for the "Flags" field that tells Intuition how to highlight your gadget, while RELVERIFY and GADGIMMEDIATE are values for the "Activation" field that explain when you want messages sent. The message of value 32 is a GADGETDOWN IntuiMessage. (see intuition.h for the definitions). Normally, each window has its own message port, and you can wait on both simultaneously and wake up when a message arrives at either one. You must use the Wait() function of Exec, and not the WaitPort() function, if you wish to wait on multiple ports. The often-found expression 1 << win->UserPort->mp_SigBit is just extracting the signal bit associated with your window's message port and converting it to a mask. So you might say /* Calculate signal masks for each window: */ awinmask = 1 << awin->UserPort->mp_SigBit; bwinmask = 1 << bwin->UserPort->mp_SigBit; /* Wait on both signals */ signal = Wait(awinmask | bwinmask); if (signal & awinmask) { /* Got something at window a */ while (imsg = GetMsg(awin->UserPort)) { /* Do stuff here, including ReplyMsg() */ } } if (signal & bwinmask) { /* Got something at window b */ while (imsg = GetMsg(bwin->UserPort)) { /* Do stuff here, including ReplyMsg() */ } } Alternatively, you can set up several windows to have the same message port. > The second question is a little more straight foward. When opening a >window with more then one string gadget how do you get the first gadget to >be activated so the user just starts entering data, and when he hits return >to activate the next gadget? Call ActivateGadget() to activate the string gadget. Note that the opening of the window is asynchronous, so if you do OpenWindow(...); ActivateGadget(...); it may not get activated (if the window was not fully open when the ActivateGadget() call was processed. The correct way is to also listen for ACTIVEWINDOW IDCMP messages and then ActivateGadget(). > Thank in advance. > Jerry Peter Cherna, Software Engineer, Commodore-Amiga, Inc. {uunet|rutgers}!cbmvax!peter peter@cbmvax.cbm.commodore.com My opinions do not necessarily represent the opinions of my employer.