[futurebasic] Re: [FB] GoAway Click

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2007 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Mon, 8 Jan 2007 21:36:48 -0500
Max asked:

>1. I have maybe 4 or five windows open on the screen, all staggered 
>so the titles show.
>2. The top window is the active window, say #5,( number 1 is in the back).
>3. Now I click in the GoAway (close) button of window number 2 
>(which is inactive).
>4. Window number 5 (the active one) wants to go away.
>The event is a '_inGoAway' click. So far no problem, but, how do I 
>pick up which window that click was in because it does not generate 
>a title bar click or content click for window #2.
>What I want:
>I would want window #2 to become the active window first (maybe) 
>before the GoAway action is handled so the correct window gets the 
>dispose message.
>I need some way to detect which window the GoAway click occurred in 
>after the GoAway event is picked up but before it is disposed of.
>What am I missing here.


While you can roll your own events, why not use FB's window Dialog 
handlers? They're a lot less trouble.

At any rate, maybe something like this (written hurriedly off the top 
of my head as I head back to work. I borrowed the FB gFBEvtPt& global 
in my rush.)


local fn DoEvent
dim ev           as ^EventRecord
dim @ thisWindow as ^CWindowRecord
dim as long windowPart, done

ev = event

select case ( ev.what )
// Detect mouse down
case _mButDwnEvt
// Find where in window mouse has clicked
windowPart = fn FindWindow( gFBEvtPt&, thisWindow )
long if ( thisWindow )
select case ( windowPart )
// If mouse click is in the Go Away button...
case _inGoAway
// ... animate the Go Away button...
done = fn TrackGoAway( thisWindow, gFBEvtPt& )
// ... and close the window...
call DisposeWindow( thisWindow )
// ... and return to event loop
ev.what = _nullEvt
end select
end if
end select

end fn

on event fn DoEvent

dim as long   i, x, l, t
dim as str255 s
dim as rect   r

setrect( r, 50, 50, 350, 250 )
x = 5
for i = 1 to 5
s = "Window " + str$( i )
window x, s, @r
print "Click my Go Away button to close " + s
offsetrect( r, 20, 20 )
next i

until 0