[comp.windows.x] Popup menus and X

donnelly%asd.span@VLSI.JPL.NASA.GOV (08/17/88)

    I have been studying the recently posted examples exhibiting
code for creation of popup menus in X.  I have also been studying 
the X Toolkit Intrinsics documentation, and have two questions:
    [1]  How am I to know that the text displayed in a widget
    of type commandWidgetClass is the first argument to XtCreate-
    ManagedWidget?

e.g. button=XtCreateManagedWidget("yes",commandWidgetClass,menu_bar,
                                  (Arg *)0,ZERO);
produces a button labled "yes", but where would I find that documented?

    [2]  If I understand things correctly, the procedure XtCreate-
    ManagedWidget returns a Widget.  Given this, what happens when
    several widgets have the same name, as in this sequence:
   .
   .
   .
 some_parent=XtCreateManagedWidget("menu",boxWidgetClass,toplevel,
                                  (Arg *)0,ZERO);
 button=XtCreateManagedWidget("yes",commandWidgetClass,some_parent,
                                  (Arg *)0,ZERO);
 button=XtCreateManagedWidget("no" ,commandWidgetClass,some_parent,
                                  (Arg *)0,ZERO);
   .
   .
   .
    I understand that I get two buttons labeled "yes" and "no", but
I am confused that both seem to refer to the same Widget, button.

    Could some patient soul enlighten me?

THANKS!
R. Donnelly
Lockheed, Johnson Space Center

swick@ATHENA.MIT.EDU (Ralph R. Swick) (08/17/88)

> e.g. button=XtCreateManagedWidget("yes",commandWidgetClass,menu_bar,
>                                   (Arg *)0,ZERO);
> produces a button labled "yes", but where would I find that documented?

See "X Toolkit [Athena] Widgets" section 3.1.:

  "XtNlabel specifies the text string that is to be displayed in the
   Command widget.  The default is the widget name of the Command widget."

>                                                         what happens when
>    several widgets have the same name
...
> I am confused that both seem to refer to the same Widget, button.


nothing bad.  If two peer widgets have the same name (and class), you will
be unable to independently specify resources for them.  Also, the
procedure XtNameToWidget will arbitrarily pick one instance.  The Intrinsics
don't use widget name for very much, but higher levels (such as ui
editors) might, so it's a good idea to assign unique names to widgets
sharing a common parent.