[comp.windows.x.motif] MenuBar question

may@may.pa.dec.com (G. May Yip) (10/16/90)

Hi there,
I wonder if it is legal to construct a Motif menubar such that some of
the cascade buttons don't have any pulldown menu and command button(s)
as children?  That is, I'd like to set it up such that a callback
routine is attached to the cascade button, rather than to the command
button(s) inside the pulldown menu, as is usually done.  I tried to do
some but ran into some problem :(

The callback triggered by the cascade button performs some Xlib
operations and then pops up a widget, asking user for a mouse button
click.  The problem I'm experiencing is that instead of 1 mouse button
click I need to actually click TWICE to get the thing thru.  I suspect
this is because my cascade button doesn't have any command button(s) as
children, therefore it is still waiting for the xtra mouse button
release event that is usually supplied with clicking on a  command
button inside the pulldown.  I tried to "simulate" this xtra mouse
button event (via XSendEvent) but it didn't work (the program died) -
either because Motif doesn't like XSendEvent or I wasn't doing it right.

Does any know anything about this?  Did anyone try constructing
attaching callbacks to cascade buttons rather than to command buttons?  
Any pointer will be appreciated!

Desperately awaiting your help,
/may

ohayon@snoopy.src.ricoh.co.jp (Ohayon Tsiel) (10/16/90)

One way to solve this menubar problem is to create instead of a 
cascade button a push button. The only thing that will happen is
that you will get the following warning message:

Warning:
   Name:
   Class: XmRowColumn
   Attempt to add wrong type child to a homogeneous RowColumn widget

 Then add callback to this button using the usual XtAddCallback function;

 This sould work since I do it all the time.


 T. Ohayon

slh@wolf.cs.washington.edu (Scott Heyano) (10/16/90)

	I've done this---make the cascade buttons of a menubar have
	no pulldown panes and just use them as buttons---it seemed
	straight forward.
	Just create the menubar and add the cascade buttons with callbacks.

marbru@auto-trol.UUCP (Martin Brunecky) (10/16/90)

In article <1990Oct15.232357.17960@wrl.dec.com> may@may.pa.dec.com (G. May Yip) writes:
>Hi there,
>I wonder if it is legal to construct a Motif menubar such that some of
>the cascade buttons don't have any pulldown menu and command button(s)
>as children?  That is, I'd like to set it up such that a callback

  I don't know if it's legal, but I have tons of test programs where
  I create the Help button with nothing hanging off it. And the button
  is alive and doing well, incl. callback activation.
  
  The only thing that stops working is Motif traversal, which seems
  to be smart enough to figure out I have no submenu out there, and
  thus does not let me to use keyboard to get to it. In fact, it
  would be kinda difficult, as the -> key only pulls down the menu
  (which is not there), and there is no key to act on my Help button.

  However, this is Motif 1.0, may be 1.1 is ... different.


-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky [BORN TO BASH UIL]                  marbru@auto-trol.COM
(303) 252-2499                                 {...}ncar!ico!auto-trol!marbru
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

carl@quad1.quad.com (Carl Priddy) (10/18/90)

In article <1990Oct15.232357.17960@wrl.dec.com>, may@may.pa.dec.com (G. May Yip) writes:
> I wonder if it is legal to construct a Motif menubar such that some of
> the cascade buttons don't have any pulldown menu and command button(s)
> as children?  That is, I'd like to set it up such that a callback
> routine is attached to the cascade button, rather than to the command
> button(s) inside the pulldown menu, as is usually done.  I tried to do
> some but ran into some problem :(
> 
 Yes, it is legal to have a cascade button on a menu bar act like a regular
old pushbutton. That is, if the XmNsubMenuId resource is NULL, then there is
no menu to be managed when the button is activated. This is a method of
"mixing" pulldown menus and pushbuttons on the menu bar which does not give
the warning about "mixing children in a homogeneous something or other"
(who dreams these messages up?). As far as I can tell, all that is required
to have this work just like you want is to make sure that the XmNsubMenuId
is NULL, and attach your activate callback. 
carl. 

jan@echo.canberra.edu.au (Jan Newmarch) (10/18/90)

ellis@osf.org writes
> 
> > I wonder if it is legal to construct a Motif menubar such that some of
> > the cascade buttons don't have any pulldown menu and command button(s)
> > as children? 
> 
> The Motif Style Guide requires that a menu bar may only be populated with
> cascade buttons.
> 
>   -- Ellis

 I think this needs some more clarification from an OSF Style guru as
to what you can or should do. You can only put a cascade button in a
menu bar. Fine - it is a homogenous widget, so no problem.
But from Motif style guide (Motif 1.0) paraphrased: menus have titles
(section 7.2.1), so what appears in the cascade button with a menu must 
be its title. In section 5.1.1 'commands are not included as topics in
the menu bar because they would prohibit browsing the menu topics'. And 
that's it! This last bit seems to be odd: I don't know what a command
is. It certainly isn't just a cascade without a menu but with a callback,
because you can browse them with the mouse quite happily.

Kee Hinckley suggested that I should avoid this by having a `dummy'
title:
        ----------------
        | File | foo   |
        ----------------
               | Toggle|
               ---------
but that just looks odd. His desire for a `default' menu selection
may also break the rule where clicking on a menu title enables keyboard
traversal.

I tried the Common User Access Advanced Interface Guide and that told
me nothing.

I asked one of my Microsoft Windows programming colleagues and got this:
If the button has a submenu, the button gives its title. If it invokes
a dialog, it should be followed by ellipses `...'. If it is a single command,
follow it with a `!'. e.g.
        ---------------------------
        | File | Toggle! | Help... |
        ---------------------------
As an example he showed me `shaker'  from the Microsoft Application
developers Toolkit using exactly these conventions. Microsoft appears
quite happy about buttons without submenus. (In passing, at least one of
the Motif examples (xmfonts?) breaks the `...' style.m)

Before we spend too much time worrying about whether some aspects of
keyboard traversal or the number of mouse clicks required are bugs
or features, could someone from OSF (or elsewhere) tell us what  is good,
bad or recommended, please.

+----------------------+---+
  Jan Newmarch, Information Science and Engineering,
  University of Canberra, PO Box 1, Belconnen, Act 2616
  Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999

  ACSnet: jan@ise.canberra.edu.au
  ARPA:   jan%ise.canberra.edu.au@uunet.uu.net
  UUCP:   {uunet,ukc}!munnari!ise.canberra.edu.au!jan
  JANET:  jan%au.edu.canberra.ise@EAN-RELAY

+--------------------------+

ellis@osf.org (10/18/90)

> I asked one of my Microsoft Windows programming colleagues and got this:
> If the button has a submenu, the button gives its title. If it invokes
> a dialog, it should be followed by ellipses `...'. If it is a single command,
> follow it with a `!'. e.g.

The Motif Style Guide at present does not support pushbuttons
in the menubar (either for direct action or for dialog popup),

The term "pushbutton" in the style guide is generic.
So the style guide prohibition holds whether the pushbutton
is implemented by XmPushButton, or simulated
by an XmCascadeButton without a submenu.

My sense is that it is unlikely this will be changed.
I believe the feeling among the OSF members that participate
in the Motif style guide group is that pushbuttons that are so important
as to not (just) be in a submenu should be placed across the bottom of
the window, and that the menubar just be reserved for cascade
buttons.

(btw, the ellipsis convention is recommended in the style guide for
pushbuttons that popup dialog boxes.  These can appear in
menus or in a workarea.)

  -- Ellis Cohen
     Motif Style Guide guru