Dynamic menus on base widget using MBAR [message #21146] |
Thu, 10 August 2000 00:00  |
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   |
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   |
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 #21251 is a reply to message #21146] |
Mon, 14 August 2000 00:00   |
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 #21690 is a reply to message #21146] |
Tue, 12 September 2000 13:21  |
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
|
|
|