TrackGoAway
TrackGoAway
Keep close box highlighted while mouse down WindowPtr theWindow ; window containing close box Point thePoint ; Point in go-away box where button pressed returns Did the user really decide to close the window?
Use this function to take care of tracking the mouse when it gets pressed in
the close region of a window. It highlights the close box as long as the mouse is
inside of it and retains control while the button is down.
theWindow identifies the window containing the close box in which the mouse
was pressed. It is normally a value obtained via FindWindow after it returned a value of inGoAway.
thePoint is a point in global coordinates (as obtained from an EventRecord). It should be inside the close box of theWindow.
Returns: a Boolean value indicating whether the button was released while the mouse was still inside of the close box. It is one of:
FALSE Released outside of the close box (don't close) TRUE Released inside the close box (close the window)
Notes: When this function returns FALSE, it means that the mouse was moved outside of the close box before the button was released. In that case, the
appropriate action is to do nothing. A return value of TRUE indicates that the window should be closed.
This function retains control until the button is released. Highlighting and
unhighlighting is performed automatically as the mouse moves into and out
of the close box.
Example
#include <Windows.h>
#include <Events.h>
/* ... */
short wPart;
/* ...fragment of a main event loop assumes window is open... */
switch ( myEvent.what ) {
case mouseDown:
if ( (wPart==inGoAway) && ( whichWindow==myWindow) ) {
/* (save the file, close the window, etc.) */
}
}
break;
}
case keyDown:
/* ...( etc. )... */
}