Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!iuvax!pur-ee!pur-phy!sho From: sho@pur-phy (Sho Kuwamoto) Newsgroups: comp.sys.mac.programmer Subject: Re: Highlight "OK" buttons Keywords: Dialogs Message-ID: <1394@pur-phy> Date: 8 Sep 88 16:08:49 GMT References: <3316@homxc.UUCP> <16727@apple.Apple.COM> <27471@think.UUCP> <3186@tekig4.TEK.COM> Reply-To: sho@newton.physics.purdue.edu.UUCP (Sho Kuwamoto) Organization: Purdue Univ. Physics Dept., W. Lafayette, IN Lines: 52 In article <3186@tekig4.TEK.COM> bradn@tekig4.TEK.COM (Bradford Needham) writes: >I used to avoid highlighting default buttons because it seemed so complex. >Now I let the Dialog Manager handle button highlighting. Here's how: > > In MacDraw, draw a thick-lined round-cornered rectangle. > Select the rectangle and copy it to the clipboard. > > In ResEdit, paste your clipboard into a new PICT resource. > Create a new PICT element in your dialog, giving your newly created > PICT as the resource to show. > Edit the rectangle of the new dialog element so it outlines > your default button. > > Now when you display the dialog, the Dialog Manager will draw the > PICT rectangle that outlines your default button. > Here is what I do to hilight buttons. It's not pretty, but it sort of works. Install it as a userItem which is big enough to cover all the buttons you might want to hilight, and set oldItem=0 and whichItem to whatever you want hilighted. If you want to hilight a different button, change whichItem and call an invalRect, or call the routine directly if you want to avoid redreawing the buttons themselves. The reason I do this is because in maybe half of my dialogs, I ask the user for input, and I want Cancel selected if there is no input in the appropriate EditText items. Cheers. pascal void OutlineButton(theWindow, itemNo) WindowPtr theWindow; short itemNo; { pnState savePen; short type; Handle ignore; Rect box; GetPenState(&savePen); PenSize(3,3); /* don't need to erase the old one if it is the same, or if it doesn't exist */ if(oldItem > 0 && oldItem != whichItem){ PenPat(&white); GetDItem(theWindow, oldItem, &type, &ignore, &box); InsetRect(&box, -4, -4); FrameRoundRect(&box, 16, 16); } /* need to draw the new one even if it is the same, because of update evts. */ PenPat(&black); GetDItem(theWindow, whichItem, &type, &ignore, &box); InsetRect(&box, -4, -4); FrameRoundRect(&box, 16, 16); oldItem = whichItem; SetPenState(savePen); }