Changing the selection on an option menu in code. - Motif

This is a discussion on Changing the selection on an option menu in code. - Motif ; I am attempting to use code to change the selection on an option menu. I tried using XmNmenuHistory, but the displayed widget does not change. I even tried (in desperation) unmanaging all of the menu buttons except the target, and ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Changing the selection on an option menu in code.

  1. Changing the selection on an option menu in code.


    I am attempting to use code to change the selection on an option menu. I
    tried using XmNmenuHistory, but the displayed widget does not change.

    I even tried (in desperation) unmanaging all of the menu buttons except the
    target, and then remanaging them. No luck. Nothing changes what is shown
    when the pulldown menu is hidden.

    Thanks,
    Matt

  2. Re: Changing the selection on an option menu in code.

    Matthew Buckley wrote:
    > I am attempting to use code to change the selection on an option menu. I
    > tried using XmNmenuHistory, but the displayed widget does not change.
    >
    > I even tried (in desperation) unmanaging all of the menu buttons except the
    > target, and then remanaging them. No luck. Nothing changes what is shown
    > when the pulldown menu is hidden.


    I am using this function with success:

    void setMenuHistory(Widget w, int num)
    {
    int numChildren;
    WidgetList wList; /* not allocated by getValue, so do not free */
    Widget popRC;

    XtVaGetValues(w, XmNsubMenuId, &popRC, NULL);
    XtVaGetValues(popRC, XmNnumChildren, &numChildren, XmNchildren, &wList,
    NULL);
    if (num XtVaSetValues(w, XmNmenuHistory, wList[num], NULL);
    }

    Call this function on a widget you get from XmCreateOptionMenu,
    not on the pulldown menu.

    Hope this helps,

    DuĊĦan Peterc
    http://www.arahne.si

  3. Re: Changing the selection on an option menu in code.

    On Feb 5, 9:05*pm, "Matthew Buckley"
    wrote:
    > I am attempting to use code to change the selection on an option menu. *I
    > tried using XmNmenuHistory, but the displayed widget does not change.
    >
    > I even tried (in desperation) unmanaging all of the menu buttons except the
    > target, and then remanaging them. *No luck. *Nothing changes what is shown
    > when the pulldown menu is hidden.
    >
    > Thanks,
    > Matt


    XtVaSetValues( XtParent(desiredButton), XmNmenuHistory, desiredButton,
    NULL );
    --
    Fred Kleinschmidt

  4. Re: Changing the selection on an option menu in code.

    Thanks to both you and Fred! It turns out that I was building my menu
    slightly wrong, and both replies helped point me to my problem.

    Thanks a lot,
    Matt

+ Reply to Thread