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

Home » Public Forums » archive » mbar and event handlers
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
mbar and event handlers [message #5356] Wed, 06 December 1995 00:00 Go to next message
Runar J|rgensen is currently offline  Runar J|rgensen
Messages: 6
Registered: December 1995
Junior Member
I'm having some problems with eventhandlers and mbar. I'll illustrate
with some sample code:

First the event handler. Then the widget creating routine.

PRO menu_base_Event, Event
widget_control,Event.Id,GET_UVALUE=Ev
.
.
end

PRO root
ROOT = widget_base(mbar=menu_base,...)
HelpMenuDesc = [...]
HelpMenu = cw_pdmenu(menu_base, /mbar, HelpMenuDesc,...)

widget_control,root,/realize
xmanager,'menu_base',menu_base
end

This works fine, but then I want to add a couple of new buttons in a
sub_base of ROOT. This is were everything goes wrong.

sub_base = widget_base(ROOT)
button=widget_button(sub_base,...)

The button does not recognize sub_base nor ROOT. Do I need an additional
eventhandler for these buttons?

Runar Jxrgensen

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-
Runar Jorgensen ||
University of Oslo || Phone: +47 2285 5663
Department of Physics || Telefax: +47 2285 5671
P.O.Box 1048 Blindern || email: runar.jorgensen@fys.uio.no
0313 Oslo; Norway ||
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-
Re: mbar and event handlers [message #5484 is a reply to message #5356] Fri, 08 December 1995 00:00 Go to previous messageGo to next message
Ken Knighton is currently offline  Ken Knighton
Messages: 44
Registered: May 1995
Member
Runar J|rgensen <runar.jorgensen@fys.uio.no> wrote:
>>> This is because you are telling xmanager to assign the event handler
>>> to the menu bar base instead of the top level base.
>
> Not quite. The menu bar base is the top (or main, root) base.

Yes, quite. No, it is not. The widget created by the MBAR keyword is the
first child of the top level base widget. The menu bar buttons created
under the menu bar id are grandchildren of the top level base. The button
you were creating in your previous post is the second child of the top
level base.

TLB
/ \
MBAR Button1
|
Menu Buttons

In order to see this, create the widgets and realize them, but do not call
the xmanager. Then use widget_info(id, /child), widget_info(id, /name),
and widget_info(id, /sibling) to see what types of widgets that you get
and who is related to whom.

Now, as far as handling the events, when xmanager is called with a name,
and a widget id, it tacks the string '_event' onto the end of the name and
then uses widget_control, widget_id, event_pro=name to assign this
procedure name as the event handler for widget_id. All events that occur
in widgets underneath this widget_id trickle up the widget hierarchy until
they reach widget_id and are thenhandled by this event handler. If
widget_id is not the top level base id (root in your original post) but
instead is a child of the top level base, then there is no event
processing being done for the top level base widget and any of its
children that do not have an event handler assigned. As far as the event
handler name goes, this can be made anything by using the
event_handler='...' keyword to xmanager.

My response to your original post fixed the problems with your code as
listed.

>
> My point is that unless the event handler routine is named according
> to the menu bar base it will not respond to events generated by any
> item in the menu bar. But it is responding fine to events generated by e.g.
> a button (child widget of top level base).

My point is that you do not know what you are talking about. I have written numerous widget applications using MBAR and they all w=
ork. Yours does not. Hmmmmm. I suggest that you look at some code that works and see what it does and emulate it. I also suggest=
that you read the IDL documentation. A little experimentation might also be helpful.

>
> But if the event handler routine is named after the menu bar name, it will
> respond to menu bar events but not to e.g. button widgets even if they are
> child of the same base.

I told you why this is in my first post and explained it a little more above.

> BTW, the base of a button can not be the name of
> the menu bar. I've tried.

Hmmmm. Just like it says in the manual. This must mean that a menu bar base is not the top level base as you were saying earlier.

Ken Knighton knighton@gav.gat.com knighton@cts.com
Fusion Division
General Atomics
San Diego CA
Re: MBAR [message #24864 is a reply to message #5356] Tue, 24 April 2001 07:16 Go to previous message
Dominic R. Scales is currently offline  Dominic R. Scales
Messages: 12
Registered: April 2001
Junior Member
Ben Tupper wrote:
>
> Hello,
>
> I'm not sure that it is possible to have the Menu Bar have non-menu buttons.
> The online help states that, 'This widget ID can then be used to fill
> the menubar with pulldown menus.'
>
> You can modify the code slightly (shown below) to make a mock menu bar.
> I just tried the following on a MAC; it looks slightly different than
> the typical menu bar (created by the top level widget base) but it
> performs as you wish.
>
> Ben
> ...
> --
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 180 McKown Point Rd.
> W. Boothbay Harbor, ME 04575
> btupper@bigelow.org

Hi Ben,
thanks very much for your solution. It's a VERY close approximation
to what I want.

Anybody have ideas how to make the highlighting arount the buttons
disappear, so that the user can't tell the difference to a proper mbar?

Cheers,
Dominic
--
Dipl. Phys. Dominic R. Scales | Aero-Sensing Radarsysteme GmbH
Tel: +49 (0)8153-90 88 90 | c/o DLR Oberpfaffenhofen
Fax: +49 (0)8153-908 700 | 82234 Wessling, Germany
WWW: aerosensing.de | email: Dominic.Scales@aerosensing.de
Re: MBAR [message #24867 is a reply to message #5356] Tue, 24 April 2001 05:24 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Hello,

I'm not sure that it is possible to have the Menu Bar have non-menu buttons.
The online help states that, 'This widget ID can then be used to fill
the menubar with pulldown menus.'

You can modify the code slightly (shown below) to make a mock menu bar.
I just tried the following on a MAC; it looks slightly different than
the typical menu bar (created by the top level widget base) but it
performs as you wish.

Ben


;------START HERE

pro my_menu_event, ev

widget_control, ev.id, get_uvalue=uval

case uval of
'OPEN' : print, uval
'PRINT' : print, uval
'DONE' : widget_control, ev.top, /destroy
else :
endcase

end


pro my_menu
;create the base widget without retrieving a menu bar widget.
base = WIDGET_BASE(TITLE = 'My Menu')

;create your own base widget to serves as the menu bar
bar = WIDGET_BASE(base, ROW = 1)

f_menu = WIDGET_BUTTON(bar, VALUE='File', /MENU)
file_open = WIDGET_BUTTON(f_menu, VALUE='Open', UVALUE='OPEN')
file_print = WIDGET_BUTTON(f_menu, VALUE='Print', UVALUE='PRINT')
file_done = WIDGET_BUTTON(f_menu, VALUE='Done', UVALUE='DONE')

bttn1=WIDGET_BUTTON(bar, VALUE='Done',UVALUE='DONE')

widget_control, base, /realize
xmanager, 'my_menu', base

end
;-------------END HERE

Ben

"Dominic R. Scales" wrote:
>
> Hi all,
>
> I have a question regarding MBAR:
> is it possible to have an entry at the main level of mbar
> acting as simple button and not as start of a menu?
> or
> How do I make the 'Done'-button bttn1 do what it is supposed to?
>
> Cheers,
> Dominic
>
> P.S. and..., oh yes, /MENU seems to be the default

--
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd.
W. Boothbay Harbor, ME 04575
btupper@bigelow.org
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to read two-bytes variables from a file saved in Mac?
Next Topic: changing window icons

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

Current Time: Wed Oct 08 14:01:19 PDT 2025

Total time taken to generate the page: 0.01025 seconds