hartkopf@tramp.Colorado.EDU (HARTKOPF JEFFREY M) (05/20/89)
I have a couple of questions for some Apple IIGS toolbox wizard :-) out there. I'd greatly appreciate any answers, but please give any examples in Pascal or C since I don't know assembly. Thanks. 1) How does one disable (dim) and enable a menu? I know you can do this to a menu ITEM with the toolbox calls DisableMItem and EnableMItem, but I can't seem to find out how to dim a menu itself. 2) How would you make a button in a custom dialog box (say a Cancel button) correspond to a keypress (like Apple-. or Esc)? The default button seems to automatically correspond to Return, but what about others? 3) How would you display standard icons in a custom dialog box? 4) How do you activate the arrows of a scroll bar in a custom dialog box? I can move the white box along the bar with the mouse, but nothing happens when I press the mouse on the end arrows or the shaded part inside. Thanks so much for any help. -- Jeff Hartkopf
jazzman@claris.com (Sydney R. Polk) (05/22/89)
From article <8935@boulder.Colorado.EDU>, by hartkopf@tramp.Colorado.EDU (HARTKOPF JEFFREY M): > I have a couple of questions for some Apple IIGS toolbox wizard :-) out > there. I'd greatly appreciate any answers, but please give any examples in > Pascal or C since I don't know assembly. Thanks. > > 1) How does one disable (dim) and enable a menu? I know you can do this to a > menu ITEM with the toolbox calls DisableMItem and EnableMItem, but I can't seem > to find out how to dim a menu itself. You need to call SetMenuFlag. There are several options to SetMenuFlag, but I think only two apply to what you want. Here is how you disable a menu: SetMenuFlag(disableMenu, MyMenuId); where MyMenuId is the number of the menu. You would call this with the value enableMenu to turn it back on. > 2) How would you make a button in a custom dialog box (say a Cancel button) > correspond to a keypress (like Apple-. or Esc)? The default button seems to > automatically correspond to Return, but what about others? This is done in the dialog filter. Basically you need to write a routine and pass it to the dialog manager. The following example is representative. /* This is in the dialog loop. */ while (((itemHit = ModalDialog(*MyFilterProc+$80000000)) != OK ) || (itemHit != Cancel) Please note that I program in assembly and the passing of the filter proc is probably not how you are supposed to do it. I haven't touched C in about two years. Anyway, MyFilterProc will be called before the standard dialog filter. That's why you have to add $80000000. If you don't the Dialog Manager will expect you to handle everything. So here is what my filter might look like: extern pascal int MyFilter(theDialogPtr,eventPtr,ItemHit) *Dialog theDialogPtr, *EventRecord eventPtr, *int ItemHit; { switch eventPtr->what { case mouseDown: ; case mouseUp: ; case keyDown: { if ((char (eventPtr->oMessage) == ESC) { *ItemHit = Cancel; /* Insert code to blink the button */ return (TRUE); } } default: return (FALSE); } } The basic idea is you figure out from the event record passed in what is supposed to happen. If the dialog manager can handle the event, return false. If the filter did return TRUE. What I did up there is change what the dialog manager thought was the item hit. Basically, it gives you a pointer to some space where you dtermine what item was hit. > 3) How would you display standard icons in a custom dialog box? There is an item defined in the dialog manager called iconItem. It has its own template definition and everything. > 4) How do you activate the arrows of a scroll bar in a custom dialog box? I > can move the white box along the bar with the mouse, but nothing happens when > I press the mouse on the end arrows or the shaded part inside. Basically, you either need to write a custom tracking procedure that the address of is in the template of the item. Read _TrackControl in the Toolbox reference. Basically, you need to thoroughly read the Toolbox Reference manuals to answer your questions. If you then have a lot of problems then ask around. Every one of your questions is answered in Volume 1 Toolbox. I know the sheer size of it is imtimidating, but there is really no OTHER way to learn this shit. It takes awhile. > Thanks so much for any help. > > -- Jeff Hartkopf -- Syd Polk | Wherever you go, there you are. jazzman@claris.com | Let the music be your light. GO 'STROS! | These opinions are mine. Any resemblence to other GO RICE! | opinions, real or fictitious, is purely coincidence.
dlyons@Apple.COM (David Lyons) (05/23/89)
In article <8935@boulder.Colorado.EDU> hartkopf@tramp.Colorado.EDU (HARTKOPF JEFFREY M) writes: [...] (Syd dealt with most of the questions already.) >3) How would you display standard icons in a custom dialog box? AlertWindow may help you, too, if you just need common icons in a box with some text and one or more buttons. See Apple IIgs Technote #48: All About AlertWindow. >-- Jeff Hartkopf --Dave Lyons, Apple Computer, Inc. | DAL Systems AppleLink--Apple Edition: DAVE.LYONS | P.O. Box 875 AppleLink--Personal Edition: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.