1

Using the Motif tool kit, we can create arrow Buttons using the API "XmCreateArrowButton".

Now when an arrow button is clicked on, the button is selected and remains in the selected state. There is a black border drawn around the arrow button.

Is there a way that when the arrow button is clicked on, the button gets selected and then becomes unselected.

The problem here is that if the button always remains in the selected state, it does not respond to other keyboard events ( such as hitting the ENTER Key ).

Thanks in advance for your help.

arun nath
  • 773
  • 1
  • 6
  • 11

1 Answers1

2

You are probably missing the arm and disarm callbacks. I'm doing this the old fashioned way because I've never used XmCreateArrowButton before. The old fashioned way only ever uses XtVaCreateManagedWidget. It will be something like

Widget arrow = XtVaCreateManagedWidget("arrow",
    xmArrowButtonGadgetClass, container, /* container will be something like a rowcol widget*/
    XmNarrowDirection, XmARROW_UP,
    NULL);
XtAddCallback(arrow, XmNarmCallback, ouch, 10);
XtAddCallback(arrow, XmNdisarmCallback, ouch, 10);
...
void ouch(Widget w, XtPointer client_data, XtPointer call_data)
{
   int value = (int) client_data; /* this will be the 10 passed in */
   XmArrowButtonCallbackStruct* cbs = (XmArrowCallbackStruct*) call_data;

   switch (cbs->reason)
   {
   case XmCR_ARM:
       /* Pressed */
       ...
       break;

   case XmCR_DISARM:
       /* released */
       ...
       break;

   default:
       /* do nothing */
       break;
   }
}
cup
  • 7,589
  • 4
  • 19
  • 42
  • Thanks for your reply. So does this mean in the XmCR_DISARM event, I can shift the focus to some other UI element. How does that work? – arun nath Mar 06 '14 at 13:56
  • 1
    In the disarm event, doesn't need to do anything: you just catch it to say you're handling it and then do nothing. Do you really want to change focus or do you want the user to do it? Intelligent focus movement is not advisable: most forms of intelligence just annoy users. Do you have access to volume 4 and 6a of X Window System manuals? Most of what you're asking is in there. – cup Mar 06 '14 at 14:59