[comp.sys.mac.programmer] Width of popup menus

austing@Apple.COM (Glenn L. Austin) (05/31/90)

mcdonald@fornax.UUCP (Ken Mcdonald) writes:

>Kinda wondering if anyone out there has come up with a nice solution
>to this problem . . .

>It's easy to set the size of the popup menu field in  a dialog, when
>the popup menu is constant--just give it the width of the menu.  But
>what about when things might be added to or removed from the menu.  If
>the box as drawn in the dialog ends up wider than the menu, then clicking
>too far to the right pops up the menu, without actually having the cursor
>in the menu.  The obvious (only, I guess) solution is to resize the box
>in the dialog, whenever the menu contents change.  Is this an Apple-
>approved solution?  Should I change the size of the box every time the
>user selects a new item?  What a pain!

To quote Inside Mac:
    You can use CalcMenuSize to recalculate the horizontal and vertical
dimensions of a menu whose contents have been changed (and store them
in the appropriate fields of the menu record). CalcMenuSize is called
internally by the Menu Manager after every AppendMenu, SetItem,
SetItemIcon, and SetItemStyle call.

Personally, if I'm changing a popup menu, I go ahead and redraw the box.
Ugly, yes.  Prettier than a popup appearing "inside" my box, however...

-- 
-----------------------------------------------------------------------------
| Glenn L. Austin               | "Turn too soon, run out of room,          | 
| Auto Racing Enthusiast and    |   Turn too late, much better fate"        |
| Communications Toolbox Hacker |   - Jim Russell Racing School Instructors |
| Apple Computer, Inc.          | "Drive slower, race faster" - D. Waltrip  | 
| Internet:   austing@apple.com |-------------------------------------------|
| AppleLink:  AUSTIN.GLENN      | All opinions stated above are mine --     |
| Bellnet:    (408) 974-0876    |                who else would want them?  |
-----------------------------------------------------------------------------