Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cbmvax!ken From: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Newsgroups: comp.sys.amiga.programmer Subject: Re: Gadget "BUG" Keywords: GADGETS|YUCK Message-ID: <22172@cbmvax.commodore.com> Date: 5 Jun 91 14:48:12 GMT References: <1991Jun05.081036.20165@disk.uucp> Reply-To: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Organization: Commodore, West Chester, PA Lines: 52 In article <1991Jun05.081036.20165@disk.uucp> specter@disk.uucp (Byron Max Guernsey) writes: >I'm having a small problem with the gadget interface in a program I have >written. At times the gadgets seem to get offset:: when I click on one >gadget another gadget's operation is performed. I think it happens after >quickly clicking twice on one gadget. It extends to the system gadgets in >my window as well...the close gadget gets offset to where I click on it and >nothing happens, then I go down and click on a gadget in my window and it >closes the window. :) If I had to guess, I would say that your event loop is wrong. When Wait() returns, you have to get all of the messages off of the port. Are you doing something like: while (!done) /* example of how NOT to process messages */ { Wait(...); /* Check for a message, process if available. ** Take only the first message and return. */ if (NULL != (msg = GetMsg(...))) { done = processMessage(msg); ReplyMsg(msg); } } This will clear the signal from the port, but only get one message at a time. If there are two messages waiting, one will stay on the port but the Wait() will not return until the next message arrives and sets the signal. This would give the behavior that you indicated (the window not closing until you hit the next gadget.) Try something like: while (!done) /* example of how to process messages */ { Wait(...); /* Get all messages until done or all of the messages ** have been removed from the port. */ while ((!done) && (NULL != (msg = GetMsg(...)))) { done = processMessage(msg); ReplyMsg(msg); } } -- -- Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines uucp: ken@cbmvax.commodore.com or ...{uunet,rutgers}!cbmvax!ken bix: kfarinsky