[comp.sys.mac.programmer] UpdateEvt question

wolf@piquet.cipl.uiowa.edu (Michael J. Wolf) (06/12/91)

Situation:

	Several windows opened for my application
	Using some for copying between on offscreen grafport

Problem:

	When a dialog pops up, then is closed, the obscured
portion of the windows are also erased, so I need to update
them.  I catch the update event, check which window via
FindWindow(Where).  Then use if structure to see which 
window to update (as each may be different).  Then I do
what is need to update the window.  

Catch:

	The window only actually gets updated when the mouse
passes into the windows content region.  And it will keep
repeating the update until the mouse is moved out.  This 
occurs even when the window doesn't need updating any longer.

I call Begin and End update surrounding thje code that does
the update for each window.  So why is the update event not
being thrown out after I do the update, or likewise, why is
it continually getting an update while the mouse is in the 
window?

Should I be finding the window to update differently?

Thanks in advance.

Michael

osborn@ux1.lbl.gov (James R Osborn) (06/13/91)

In article <6446@ns-mx.uiowa.edu> wolf@piquet.cipl.uiowa.edu (Michael J. Wolf) writes:
>Situation:
>
>	Several windows opened for my application
>	Using some for copying between on offscreen grafport
>
>Problem:
>
>	When a dialog pops up, then is closed, the obscured
>portion of the windows are also erased, so I need to update
>them.  I catch the update event, check which window via
>FindWindow(Where).  Then use if structure to see which 


NO!  You are supposed to use "(WindowPtr) theEvent.message"
as the pointer to the window that needs updating.  Most likely
all of your problems are due to the fact that you are not doing
the update for the proper window.  The window manager just keeps
posting update events until your strange way of doing it finally
gets around to updating the proper window.


>window to update (as each may be different).  Then I do
>what is need to update the window.  
>
>Catch:
>
>	The window only actually gets updated when the mouse
>passes into the windows content region.  And it will keep
>repeating the update until the mouse is moved out.  This 
>occurs even when the window doesn't need updating any longer.
>
>I call Begin and End update surrounding thje code that does
>the update for each window.  So why is the update event not
>being thrown out after I do the update, or likewise, why is
>it continually getting an update while the mouse is in the 
>window?
>
>Should I be finding the window to update differently?

Yes, see above.

>
>Thanks in advance.
>
>Michael

You're welcome.

-- James

.------------------------------.--------------------------------------.
| James R. Osborn              | It just goes to show you it's always |
| Lawrence Berkeley Laboratory | something.  Either it's baffling     |
| osborn@ux1.lbl.gov           | tech notes or your mac is smoking.   |
| (415) 548-8464               | It's always something...             |
'------------------------------'--------------------------------------'

CAH0@bunny.gte.com (Chuck Hoffman) (06/14/91)

In article <6446@ns-mx.uiowa.edu> wolf@piquet.cipl.uiowa.edu (Michael J. 
Wolf) writes:
> I catch the update event, check which window via
> FindWindow(Where).  Then use if structure to see which 
> window to update (as each may be different).  Then I do
> what is need to update the window.  
> 
> Catch:
> 
>         The window only actually gets updated when the mouse
> passes into the windows content region.  And it will keep
> repeating the update until the mouse is moved out.  This 
> occurs even when the window doesn't need updating any longer.

The repeating update tells you that the update has not been satisfied.  
Your BeginUpdate and EndUpdate must be for a different window or
GrafPort.

> I catch the update event, check which window via
> FindWindow(Where).

Use the message field of the event record instead.  For an update event, 
this will be a pointer to the proper window.  FindWindow would only tell 
you where the mouse is.  Then be sure to select the window or do something 
else to set the GrafPort to the window you want before doing the 
Begin/EndUpdate.

Good luck.  I have some code I can send if you need it.


Chuck Hoffman, GTE Laboratories, Inc.    |  I'm not sure why we're here,
cah0@bunny.gte.com                       |  but I am sure that while we're
Telephone (U.S.A.) 617-466-2131          |  here, we're supposed to help
GTE VoiceNet: 679-2131                   |  each other.
GTE Telemail: C.HOFFMAN                  |