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

Home » Public Forums » archive » Dynamic menus on base widget using MBAR
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
Dynamic menus on base widget using MBAR [message #21146] Thu, 10 August 2000 00:00 Go to next message
Ricardo Fonseca is currently offline  Ricardo Fonseca
Messages: 13
Registered: February 2000
Junior Member
Hi All

Is there a way to dynamically change the menu on a base widget? When I begin
my program I create a menu using the MBAR keyword on the WIDGET_BASE
function. While it is running, and depending on user input, I'd like to
change the menu to a completely different one.

So far I've attempted to destroy the old button widgets and regenerating the
menu, but it's not working.

Any Ideas?

Thanks in advance, Ricardo
Re: Dynamic menus on base widget using MBAR [message #21245 is a reply to message #21146] Mon, 14 August 2000 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Pavel Romashkin (promashkin@cmdl.noaa.gov) writes:

> I am sorry. I am replacing the "most conventional way" in my post with
> "RSI recommended way". This way, David will be not out of step with
> everyone else but, on the contrary, ahead of the pack and diverged from
> the evil way :-)
> Cheers,
> Pavel
>
> P.S. To get at least a tiny bit of my trashed reputation back, I'll say
> that I do use Value of button widgets to determine which one sent an
> event. However, I am really old-fashioned when it comes to other widgets
> and use their Uvalue. I admit to using cw_pdmenu for menu items, when I
> needed an easy, no-tricks menus. Sorry. I am disqualified :-(

You can probably sneak back in under the little used
"Most Obsequious to the Judges" category. :-)

Cheers,

David

P.S. I really liked that "ahead of the pack" nonsense. :-)

--
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: Dynamic menus on base widget using MBAR [message #21246 is a reply to message #21146] Mon, 14 August 2000 00:00 Go to previous messageGo to next message
promashkin is currently offline  promashkin
Messages: 169
Registered: December 1999
Senior Member
David Fanning wrote:

> I'm surprised to learn that button UVALUES are the "most
> conventional way" to learn which button was selected in
> event handlers, since I only rarely use this method. I
> prefer to use the button value itself, since this value
> is always obvious to me when I look at the button and I
> need all the visual clues I can get when I am writing
> programs. :-(

I am sorry. I am replacing the "most conventional way" in my post with
"RSI recommended way". This way, David will be not out of step with
everyone else but, on the contrary, ahead of the pack and diverged from
the evil way :-)
Cheers,
Pavel

P.S. To get at least a tiny bit of my trashed reputation back, I'll say
that I do use Value of button widgets to determine which one sent an
event. However, I am really old-fashioned when it comes to other widgets
and use their Uvalue. I admit to using cw_pdmenu for menu items, when I
needed an easy, no-tricks menus. Sorry. I am disqualified :-(
Re: Dynamic menus on base widget using MBAR [message #21249 is a reply to message #21146] Mon, 14 August 2000 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Pavel Romashkin (promashkin@cmdl.noaa.gov) writes:

> Menu items then could have
> different Uvalues and be used in the most conventional way in event handlers.

I'm surprised to learn that button UVALUES are the "most
conventional way" to learn which button was selected in
event handlers, since I only rarely use this method. I
prefer to use the button value itself, since this value
is always obvious to me when I look at the button and I
need all the visual clues I can get when I am writing
programs. :-(

But then again, I've always been slightly out of step
with everyone else. It's a burden I've had to bear
all my life. :-)

Cheers,

David

P.S. Let's just say a vote from me in any election
is almost a kiss of death. :-(

--
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: Dynamic menus on base widget using MBAR [message #21251 is a reply to message #21146] Mon, 14 August 2000 00:00 Go to previous messageGo to next message
promashkin is currently offline  promashkin
Messages: 169
Registered: December 1999
Senior Member
David Fanning wrote:
> Today, I went back and looked at the code more carefully.
> I think my original plan *was* to put it in a menu bar,
> but I had to modify my original plan. I'm guessing because
> it didn't work then.

This was the problem that a child of menu bar shared (forcefully) its
UVALUE with the menubar and the rest of menubar children. I think I
reported this for version 5.0 and was assured that such behavior was
beneficial for me. I forget what the explanation was, but I had no other
choice but to use buttons as top-level items on menu bar. Their Uvalues
were all the same, but you never use them. Menu items then could have
different Uvalues and be used in the most conventional way in event handlers.

> But I just tried it now (with the same Dynamic_Menu code
> on my web page) in a menu bar and it still works. I'm using
> IDL 5.3.1 on Windows NT 4.

I still use buttons as "insulators" between menubar and droplists of
menu items. It does work, although I am not sure if it is necessary anymore.
I use IDL 5.2 on a Mac. BTW, I have no system crashes when messing up
with widgets, including menu bars. Might be that faulty MacOS release,
you never know :-(
Cheers,
Pavel
Re: Dynamic menus on base widget using MBAR [message #21261 is a reply to message #21146] Sat, 12 August 2000 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Ricardo Fonseca (zamb@physics.ucla.edu) writes:

> I have read (your page is the first I usually go to...) but I haven't been
> able to make it work with the MBAR menu (or APP_MBAR on the Mac). In fact
> just destroying one of the buttons results in a spectacular system crash as
> soon as I use the menu (IDL 5.1.1, Mac). Any other suggestion?

About two minutes after I sent that response I thought
"I wonder why I put that pull-down menu in a button and
not on the menu bar?" But I was late for another engagement.

Today, I went back and looked at the code more carefully.
I think my original plan *was* to put it in a menu bar,
but I had to modify my original plan. I'm guessing because
it didn't work then.

But I just tried it now (with the same Dynamic_Menu code
on my web page) in a menu bar and it still works. I'm using
IDL 5.3.1 on Windows NT 4.

So I am guessing that whatever the problem was (if there
*was* a problem), it has been sorted out in the version
of IDL I'm running. I know that doesn't help you much,
but there you go. :-)

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: Dynamic menus on base widget using MBAR [message #21272 is a reply to message #21146] Fri, 11 August 2000 00:00 Go to previous messageGo to next message
Ricardo Fonseca is currently offline  Ricardo Fonseca
Messages: 13
Registered: February 2000
Junior Member
I have read (your page is the first I usually go to...) but I haven't been
able to make it work with the MBAR menu (or APP_MBAR on the Mac). In fact
just destroying one of the buttons results in a spectacular system crash as
soon as I use the menu (IDL 5.1.1, Mac). Any other suggestion?

Ricardo

> From: davidf@dfanning.com (David Fanning)
> Organization: Fanning Software Consulting
> Newsgroups: comp.lang.idl-pvwave
> Date: Thu, 10 Aug 2000 17:59:09 -0600
> Subject: Re: Dynamic menus on base widget using MBAR
>
> Ricardo Fonseca (zamb@physics.ucla.edu) writes:
>
>> Is there a way to dynamically change the menu on a base widget? When I begin
>> my program I create a menu using the MBAR keyword on the WIDGET_BASE
>> function. While it is running, and depending on user input, I'd like to
>> change the menu to a completely different one.
>>
>> So far I've attempted to destroy the old button widgets and regenerating the
>> menu, but it's not working.
>
> I wrote an article about how to do this and put it on my
> web page:
>
> http://www.dfanning.com/tips/dynamic_menus.html
>
> 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: Dynamic menus on base widget using MBAR [message #21690 is a reply to message #21146] Tue, 12 September 2000 13:21 Go to previous message
Phillip David is currently offline  Phillip David
Messages: 36
Registered: April 1999
Member
I can tell I haven't been keeping up with the newsgroup. The primary
reason to use the UValue of the button rather than the value is that you
might wish to change the value of the button (for example, you could
decide to internationalize the application and change the button values
to Swahili), yet you wish the button to continue to work as coded. If
you rely on the text printed on the button, you will be unable to change
it without major changes to your code. If, however, you use the UValue
of the button, the label on the button's face no longer matters.

Another time this makes a difference to me is when I change the value of
a button to reflect state. Some of our buttons say things like "Add
axes" until you select them. Once axes have been added, we change the
value of the text to "Remove axes". We can use the same event handler
in both cases if we rely on the UValue, but not if we use the value.

Phillip

David Fanning wrote:
>
> Pavel Romashkin (promashkin@cmdl.noaa.gov) writes:
>
>> Menu items then could have
>> different Uvalues and be used in the most conventional way in event handlers.
>
> I'm surprised to learn that button UVALUES are the "most
> conventional way" to learn which button was selected in
> event handlers, since I only rarely use this method. I
> prefer to use the button value itself, since this value
> is always obvious to me when I look at the button and I
> need all the visual clues I can get when I am writing
> programs. :-(
>
> But then again, I've always been slightly out of step
> with everyone else. It's a burden I've had to bear
> all my life. :-)
>
> Cheers,
>
> David
>
> P.S. Let's just say a vote from me in any election
> is almost a kiss of death. :-(
>
> --
> 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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Axis labels
Next Topic: slicer to movie

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

Current Time: Wed Oct 08 13:46:43 PDT 2025

Total time taken to generate the page: 0.00670 seconds