comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Can I make entries in CW_PDMENU insensitive?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Can I make entries in CW_PDMENU insensitive? [message #14397] Wed, 24 February 1999 00:00 Go to next message
Steffen Luesse is currently offline  Steffen Luesse
Messages: 1
Registered: February 1999
Junior Member
Dear all,

I am using IDL 5.2 on solaris 2.6. I want to use the CW_PDMENU routine
to create a pull-down menu in my widget programs. In principle,
everything works well. However, I am wondering if it is possible to make
some menu entries insensitive like I can do it with buttons or sliders
when they should not be used. I did not find any information about my
problem in the IDL documentation and would appreciate if anybody could
give me a hint.

Thanks in advance,

Steffen
Re: Can I make entries in CW_PDMENU insensitive? [message #14461 is a reply to message #14397] Wed, 03 March 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Stein Vidar Hagfors Haugan (steinhh@ulrik.uio.no) writes:

> 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*.

Oh, Stein Vidar, don't *even* get me started!

Of course you want an object. But do you know how
many really good programmers on this newsgroup are
deathly afraid of objects? It's an uphill battle, my
friend. :-)

Cheers,

David

P.S. I've been looking for a good compound widget
as object example for my book. I had something else
in mind, but maybe I'll code this up instead. And
if I can do it, anyone can. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Can I make entries in CW_PDMENU insensitive? [message #14465 is a reply to message #14397] Wed, 03 March 1999 00:00 Go to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
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
> get.

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]
menu->add,'Level 1c','LEVEL1C',/menu
menu->add,'Level 2a','LEVEL2A'
menu->add,'Level 2b','LEVEL2B'

We keep the object pointer in the info structure, and
later we use it like this:

;; No argument means desensitize whole menu
menu->desensitize

;; One argument means desensitize that button (or
;; submenu)
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"
method..

Regards,

Stein Vidar
Re: Can I make entries in CW_PDMENU insensitive? [message #14474 is a reply to message #14397] Tue, 02 March 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
David Foster (foster@bial1.ucsd.edu) writes:

> David -
>
> I agree that creating pulldown menus using the /MENU keyword to
> WIDGET_BUTTON() calls is very easy, and makes your code easier
> to read and maintain (especially your event handler!).
>
> But all of the limitations of CW_PDMENU mentioned above can be
> overcome by using the IDS= keyword to return a vector of the
> widget IDs for the buttons, and then using WIDGET_CONTROL to
> manage these widgets (eg. make insensitive, assign an event-handler,
> set the uvalue, etc.).

I don't dispute this. I just argue that using the button
IDs like this will make the code significantly harder to
extend and maintain over time. Since I'm not so bright that
I think of everything I need in a program at the time I write
it, extendability and maintainability is something I prize
highly. :-)

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. When it comes to programming, I
need all the help I can get.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Can I make entries in CW_PDMENU insensitive? [message #14475 is a reply to message #14397] Tue, 02 March 1999 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
David Fanning wrote:
>
> Steffen Luesse (luesse@rad.uni-kiel.de) writes:
>
>> I am using IDL 5.2 on solaris 2.6. I want to use the CW_PDMENU routine
>> to create a pull-down menu in my widget programs. In principle,
>> everything works well. However, I am wondering if it is possible to make
>> some menu entries insensitive like I can do it with buttons or sliders
>> when they should not be used. I did not find any information about my
>> problem in the IDL documentation and would appreciate if anybody could
>> give me a hint.
>
> CW_PDMENU sounds like a good idea until you actually start
> writing a widget program. Then you find you want to make
> a button insensitive, or you want to assign a special event
> handler to a button, or you want to put something in the
> user value of a button, or whatever it is, and CW_PDMENU
> doesn't let you do it.
>
> At this point you can either hack the CW_PDMENU code (ugh!), or
> you can do what I do and use the trivially easy solution of
> setting the MENU keyword on button widgets to create your
> own pull-down menus.

David -

I agree that creating pulldown menus using the /MENU keyword to
WIDGET_BUTTON() calls is very easy, and makes your code easier
to read and maintain (especially your event handler!).

But all of the limitations of CW_PDMENU mentioned above can be
overcome by using the IDS= keyword to return a vector of the
widget IDs for the buttons, and then using WIDGET_CONTROL to
manage these widgets (eg. make insensitive, assign an event-handler,
set the uvalue, etc.).

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: INSIGHT 3D Visualization ?
Next Topic: Map of the Moon's surface

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:07:24 PDT 2025

Total time taken to generate the page: 0.00700 seconds