Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ucdavis!iris!lim From: lim@iris.ucdavis.edu (Lloyd Lim) Newsgroups: comp.sys.mac.programmer Subject: Re: How to highlight buttons Keywords: button, mac, macintosh, dialog Message-ID: <6957@ucdavis.ucdavis.edu> Date: 8 Mar 90 07:23:48 GMT References: <1990Mar6.071221.3962@Neon.Stanford.EDU> <6929@ucdavis.ucdavis.edu> <288@bii.UUCP> <1990Mar6.195441.6794@Neon.Stanford.EDU> Sender: uucp@ucdavis.ucdavis.edu Reply-To: lim@iris.ucdavis.edu (Lloyd Lim) Organization: U.C. Davis - Department of Electrical Engineering and Computer Science Lines: 56 In article <1990Mar6.195441.6794@Neon.Stanford.EDU> philip@pescadero.stanford.edu writes: >I've had a few requests for this, so here is the source code. I've marked >places I haven't checked on with comments; you should do a bit of testing >before using this (seems ok when I tried it). > >This is just a quick hack. I've tried to avoid doing anything >but drawing the highlight, and to pass anything else to the deafult CDEF. >Complication: CDEFs are identified when you ask for a new control by a >number which is 16 times the resource ID of the underlying CDEF (see Inside >Mac Vol 1). > >[...] > >Missing: because the new control is not a button as far as the dialog manager >is concerned, pressing RETURN or ENTER does not select it automatically if >it's item 1 (sigh). > >[...] > >Philip Machanick >philip@pescadero.stanford.edu There are a few other things I considered when I wrote my Default CDEF: (that I can remember of the top of my head) - it's a little better to use HGetState and HSetState just in case - the outline grays if the button is disabled - the outline is the same color as the button frame - the outline looks correct even if the button isn't 16 pixels high Also, Default is a real button so there's no problem with CNTLs or pressing return or enter. It also lets you change buttons on the fly, so you could add an outline to the Open button in the SFGetFile dialog just by changing the title to Open@. I've been asking $5 for the source to Default but if you really are writing your own, you might as well benefit from the testing I did. So if you ask me nicely, I will send the source to you free via e-mail (requests via regular mail are still $5). I prefer however to make the source available on request only and also prefer that you not redistribute the source. The source is really only useful for DAs and such since you can't attach a CDEF 0 in that case. The Default source is not helpful in writing a CDEF for your own type of control because Default doesn't act like any normal control. About the only useful thing you'd get out of the source is the CDEF routine declaration and its parameters. Actually, I would be glad if Apple got its act together and eliminated the need for this stuff by just defining another variation code and adding a few lines of code to the standard CDEF 0. I think Default should work with any System but Apple is the only one who can guarantee things like that. +++ Lloyd Lim Internet: lim@iris.ucdavis.edu (128.120.57.20) Compuserve: 72647,660 US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616