Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!tank!uxc!uxc.cso.uiuc.edu!uxg.cso.uiuc.edu!uxe.cso.uiuc.edu!leonardr From: leonardr@uxe.cso.uiuc.edu Newsgroups: comp.sys.mac.programmer Subject: Re: Highlight "OK" buttons Message-ID: <226000029@uxe.cso.uiuc.edu> Date: 8 Sep 88 16:54:00 GMT References: <3316@homxc.UUCP> Lines: 54 Nf-ID: #R:homxc.UUCP:3316:uxe.cso.uiuc.edu:226000029:000:2400 Nf-From: uxe.cso.uiuc.edu!leonardr Sep 8 11:54:00 1988 ephraim@think.COM(Ephraim Vishniac) in comp.sys.mac.programmer >>In article <3316@homxc.UUCP> paco@homxc.UUCP (Herbert Throckmorton) writes: > >>>IM vol.1 mentions in the "Dialog Manager" section that one can >>>highlight the default button in a dialog as well, but IM vol.1 doesn't >>>mention how to do that deed, as far as I can tell. > >> [code, etc. was here before I removed it] > >That's how you *draw* the highlighting, which is only a partial answer >to the question of how you highlight a button. The part that people >often get wrong is *when* you highlight the button. They tend to >forget that the highlighting might need refreshment (refreshing?) >(redrawing?) when the dialog gets an update event. > >It seems like a safe tactic would be to redraw the highlighting >whenever you get any update event for the dialog, but I'm sure >somebody will point out to me a reason that's a bad idea... > An even better idea is to use a UserItem, that was you are guarenteed that the hiliting will be redrawn on update events (Dialog Manager call all User Items on updates) and you don't need a filter proc! The code that I use for my UserItem is: PROCEDURE OutlineButton(aDialog: DialogPtr; itemNo: Integer); VAR iType: integer; iHandle: Handle; iBox: Rect; BEGIN GetDItem(aDialog, 1, iType, iHandle, iBox); {I assume that OK is #1} InsetRect(iBox, - 4, - 4); PenSize(3, 3); FrameRoundRect(iBox, 16, 16); PenNormal; END; All you need to do to use this is to create a userItem (I just create it as the last item in my Dialog and I give it a rect of 0,0,0,0 since it doesn't matter) and then set this routine to it using SetDItem. +---------------------------------+-----------------------------------+ + + Any thing I say may be taken as + + Leonard Rosenthol + fact, then again you might decide+ + President, LazerWare, inc. + that it really isn't, so you + + + never know, do you?? + + leonardr@uxe.cso.uiuc.edu + + + GEnie: MACgician + MacNET: MACgician + + Delphi: MACgician + + + + + +---------------------------------+-----------------------------------+