Odd behaviour of XmComboBox.... (arrow problem)

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

Submitted by Thomas Lehmann on Tue, 02/17/2009 - 06:45. Open Motif Reference Manual (6B)
After here you will find an example code placing two combox widgets one above the other.
Idea is to select one entry of the first controlling the selectable content of the second.
Now the problem: The arrow button. Selecting an entry in the first the arrow button of
the second translates to the left (the sizes of the comboxes are remaining).

|Value A xxxxxxxxxxxxxx |\/|
|SubValueB xxxxx |\/ xxxxxx |

(x = Space) I don't know how to avoid proportional font here

Of course this is very ugly! My expectation: The arrow should never occupy more than the little space as
shown for the first combobox remaining at the right. (of course not the arrow itself does change in size
but the area the arrow is in)

Could someone help please?

kindly
Thomas

CODE:

bool testingTwoComboboxes(Widget parent)
{
if (!parent)
return false;

struct MyCallBack
{
static void selected(Widget, XtPointer data, XmComboBoxCallbackStruct*)
{
// adjusting content for first combo box.
XmStringTable tableB = (XmStringTable)XtMalloc(2 * sizeof(XmString));
tableB[0] = XmStringCreateLocalized("SubValue A");
tableB[1] = XmStringCreateLocalized("SubValue B");

Widget widget = (Widget)data;

XtVaSetValues(widget, XmNitemCount , 2
, XmNitems , tableB
, XmNvisibleItemCount, 2
, XmNselectedItem , tableB[0]
, NULL);

// cleanup
XmStringFree(tableB[0]);
XmStringFree(tableB[1]);
XtFree((char*)tableB);
}//pushed
};

// defining initial properties of the widgets.
Arg arguments[10];
Cardinal count = 0;
const bool editable = false;

// switching concrete combobox type
const unsigned int type = (editable) ? XmDROP_DOWN_COMBO_BOX
: XmDROP_DOWN_LIST;

XtSetArg(arguments[count], XmNpositionMode , XmZERO_BASED);
++count; XtSetArg(arguments[count], XmNcomboBoxType , type);
++count;

// creating widgets
Widget form = XmCreateForm(parent, "form", 0, NULL);
Widget comboA = XmCreateComboBox(form, "comboA", arguments, count);
Widget comboB = XmCreateComboBox(form, "comboB", arguments, count);

// adjusting layout (one above the other)
XtVaSetValues(comboA, XmNleftAttachment , XmATTACH_FORM
, XmNrightAttachment , XmATTACH_FORM
, XmNtopAttachment , XmATTACH_FORM
, NULL);

XtVaSetValues(comboB, XmNleftAttachment , XmATTACH_FORM
, XmNrightAttachment , XmATTACH_FORM
, XmNtopAttachment , XmATTACH_WIDGET
, XmNtopWidget , comboA
, XmNbottomAttachment, XmATTACH_FORM
, NULL);

// adjusting content for first combo box.
XmStringTable tableA = (XmStringTable)XtMalloc(2 * sizeof(XmString));
tableA[0] = XmStringCreateLocalized("Value A");
tableA[1] = XmStringCreateLocalized("Value B");

XtVaSetValues(comboA, XmNitemCount , 2
, XmNitems , tableA
, XmNvisibleItemCount, 2
, XmNselectedItem , tableA[0]
, NULL);

// cleanup
XmStringFree(tableA[0]);
XmStringFree(tableA[1]);
XtFree((char*)tableA);

XtAddCallback(comboA
,XmNselectionCallback
,(XtCallbackProc)MyCallBack::selected
,comboB);

// show
XtManageChild(form);
XtManageChild(comboA);
XtManageChild(comboB);
return true;
}//testingTwoComboboxes

Andriy Konoval

I tried your code.
But no issues appeared.
Everything looks good.

What Openmotif version do you use? And what system?
Probably issue depends on environment.