[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can I make entries in CW_PDMENU insensitive?
- Subject: Re: Can I make entries in CW_PDMENU insensitive?
- From: steinhh(at)ulrik.uio.no (Stein Vidar Hagfors Haugan)
- Date: 3 Mar 1999 10:13:07 GMT
- In-reply-to: firstname.lastname@example.org's message of Tue, 2 Mar 1999 14:47:26 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Oslo, Norway
- References: <36D3E9D9.38739E24@rad.uni-kiel.de><MPG.email@example.com><36DC5804.25F8@bial1.ucsd.edu><MPG.firstname.lastname@example.org>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:13804
David Fanning wrote:
> Adding a menu item as a button, assigning an event
> handler for it, and writing the new event handler
> can be done in a matter of minutes, as opposed to
> re-ordering my index numbers in a large event
> handler, making several mistakes that introduce
> other errors, etc.
I agree, David, that this is easily done in a few minutes -
although the situation might require a bit more than just an
event handler. You might want to (de)sensitize the button(s)
based on a number of different criteria, not just based on
events from the buttons themselves... So you'll probably
need to store the ID(s) in the info structure anyway.
Anyway, the ID extraction from the array would come directly
after the cw_pdmenu call using the IDS= keyword, so it isn't
that difficult to remember the update when you're changing
the cw_pdmenu call...
Given that button IDs for several buttons need to be stored
for later use, the difference isn't all that big... But
personally I agree that the direct method using /MENU in
widget_button is aesthetically more pleasing.
> When it comes to programming, I need all the help I can
Ok - you asked for it :-) In the case that one needs to
manipulate the status of several buttons on a pulldown menu,
the sensible thing is to write a pulldown menu *object*.
When this is done once and for all, you can forget all about
IDs and widget_control calls. Something like this (off the
top of my head, the specific mode of operation is at the
programmers discretion, of course):
menu = obj_new('mypdmenu',base,'Pull Down Menu')
menu->add,'Level 1a','LEVEL1A' ;; Second arg. is an optional
menu->add,'Level 1b','LEVEL1B' ;; identifier, [UVALUE]
We keep the object pointer in the info structure, and
later we use it like this:
;; No argument means desensitize whole menu
;; One argument means desensitize that button (or
menu->sensitize,'LEVEL1A' ;; Single button
menu->desensitize,'LEVEL1C' ;; Submenu.
The rationale behind using identifiers like 'LEVEL1A' etc is
to be independent of the actual button text (like, if
somebody translates the text to serbocroatian... :-)
You may of course specify event handlers etc. in the "add"