[futurebasic] deleting embedded check btns; ln508 woes

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2002 : Group Archive : Group : All Groups

From: "Peter Dempsey" <theviron@...>
Date: Tue, 11 Jun 2002 21:28:35 -0500
First of all I'd like to greet all you great FBers again considering my 
recent long absense!
(internet problems among others...)

Fortunately during that time I was able to do some extra experimentation and 
(I would hope) learning.  I was just working on a decently sized project 
designed to incorporate many basic interface aspects of OS X (for testing) 
when I ran into an odd window/button combination problem.  Since most of the 
following is a simple story of errors, I've sectioned off my specific 
"questions."

I built a basic "preferences" window like so:
APPEARANCE WINDOW _PrefsWnd, "Preferences",�
@r,_kFloatingWindowClass,_kWindowCloseBoxAttribute

(where r is a rect within proper bounds)

I went on to fill it with various objects, and finally got to a part where I 
wanted four buttons to be in a box with one "check on/mixed/off" button at 
top.  So, I created them:
[again ignore the rects; they shouldn't be any problem]
[also, the starting states are loaded from a prefs file.. again that part 
seems to work fine]

APPEARANCE BUTTON _AllGreetingsBtn,_activeBtn,1,0,2, 
"Greetings:",@r,_kControlGroupBoxCheckBoxProc

r.left=10+_AGMargin:r.right=r.left+_ReadDayBtnX:r.top=r.top+_AGMargin+_RMBtnY:r.bottom=r.top+_RMBtnY
APPEARANCE BUTTON 
_ReadDayBtn,_activeBtn,gPrefs.readDay,0,1,"Day",@r,_kControlCheckBoxProc
def embedbutton(_ReadDayBtn,_AllGreetingsBtn)
r.left=r.right+_AGMargin:r.right=r.left+_ReadDateBtnX
APPEARANCE BUTTON 
_ReadDateBtn,_activeBtn,gPrefs.readDate,0,1,"Date",@r,_kControlCheckBoxProc
def embedbutton(_ReadDateBtn,_AllGreetingsBtn)
r.left=r.right+_AGMargin:r.right=r.left+_ReadTimeBtnX
APPEARANCE BUTTON 
_ReadTimeBtn,_activeBtn,gPrefs.readTime,0,1,"Time",@r,_kControlCheckBoxProc
def embedbutton(_ReadTimeBtn,_AllGreetingsBtn)
r.left=r.right+_AGMargin:r.right=r.left+_ReadGreetingsBtnX
APPEARANCE BUTTON 
_ReadGreetingsBtn,_activeBtn,gPrefs.readGreetings,0,1,"Greeting",@r,_kControlCheckBoxProc
def embedbutton(_ReadGreetingsBtn,_AllGreetingsBtn)

In my dialog handling routine I properly check/uncheck and check the checks 
and nonchecks to show the proper button type.  When ran, this part also 
works fine.

The PROBLEM comes in when I specifically close _PrefsWnd.  Here's the code 
(in my dialog handler) as I think it SHOULD be:

DlgEV = DIALOG(0)
DlgID = DIALOG(DlgEV)

SELECT DlgEV'first figure out what event it was
'------------- Window events --- (id =  window ID) -----------------
CASE _wndClick'window clicked
CASE _wndClose'window closed  <--box clicked rather?
select DlgID
case _PrefsWnd
fn GetPrefs
//the above simply reads from the buttons to gPrefs
end select

window close DlgID

//end code

The application unexpectedly quits here under the LATEST version (as of the 
fifth?).
Originally, it brought up a STOP error saying that btNumSub=_AllGreetingsBtn 
(23)
So I started fiddling, figuring that I had screwed up somewhere as usual 
(and probably still true..).
I changed the window type to _kDocumentWindowClass and (go figure) it still 
brought up the error.
I continued fiddling by adding my own Button Deletion before window close 
like so:

button close -_ReadDayBtn
button close -_ReadDateBtn
button close -_ReadTimeBtn
button close -_ReadGreetingsBtn

button close -_AllGreetingsBtn

window close DlgID

//end code

At first I tried just deleted _AllGreetingsBtn but it brought up the same 
stop.  Under the arrangement above, however, it all works just 
[dandy,great].  I suppose _AllGreetingsBtn no longer counted as a "parent" 
control... or... something... (?)

So I decided that was a starting point and switched the window back to 
_kFloatingWindowClass.
Here's where I really got confusounded (both confused and confounded...)
It brought up the stop error again!  I was running out of ideas (shocker).  
Fortunately, I also got my internet back today so I decided to check staz's 
site.  I downloaded the header update and very quickly checked line 508 in 
appearance button.incl and was pleased to see it commented out (thinking 
that I was ok again).

So I tried running it again with the original setup with the new headers -- 
that is with _kFloatingWindowClass and no early button deletion.  It just 
unexpectedly quit when _PrefsWnd was closed.  It was then that I decided I 
needed help (but specifically on this perplexing problem! ;-P) and redid my 
experiments down to uncommenting and recommenting line 508 of Appearance 
Button.incl.  Additionally, I tried the old experiments with the new headers 
and came up with the same pattern of crashes and successes as I had STOPs 
and successes.   To be (more) specific:

I tried deleting the buttons before closing _PrefsWnd with _PrefsWnd as 
_kFloatingWindowClass.  It crashed.
I tried switching _PrefsWnd to _kDocumentWindowClass and deleting the 
buttons before closing it.  It worked.
Finally I tried just _PrefsWnd as  _kDocumentWindowClass and it crashed 
(again...) after I closed _PrefsWnd.

None of these had anything to do with my saving the prefs, as I did so 
before closing anything AND have tested them without saving the prefs 
(essentially, the button states).


Oddly, however, none of these problems surface when I simply quit via the 
following function.

clear local fn Quit
fn SavePrefs
end //doesn't this close the window? ;|
end fn


My apologies for being unable to simplify the situation further...

----------Summary and questions----------
1) Can you embed check buttons in check buttons in _kFloatingWindowClass 
windows in OS X? (that summarizes my intent and where it crashes I'd say...)

2) If so, where'd I go wrong?

3) Otherwise (no to #1), what strategy would reach roughly the same layout? 
(examples, I suppose, include manually drawing a box...)

I hope the questions were summary enough.   My knowledge of *FB(^3) is 
riddled with holes (cliche [accent] me say) so do send along any thoughts 
s.v.p.

-eoieaiea;eanfau trying not to get up anybody�s nose by chatting doc
(chanting "ah ah ah" [in place of dempster noise] and going back to 
starships >=-) for the time being...)
*along with everything else

Thanks!

[/me starts looking busy]



_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com