Hi,
I am using togglebuttons in my application ,I have put two togglebuttons in rowcolumn horizontally. When I click on first toggle button a file-selection box is launched. After selecting a file when I move mouse over the checked togglebutton(first one), this togglebutton changes its state repeatedly(i.e it becomes unchecked when mouse moves over this button and becomes checked when mouse is moved away from it). The other button remains in unchecked state.
Kindly help.
However, why are you posting the dialog from an XmNarmCallback? You should be using the XmNvalueChangedCallback, and posting the dialog if the 'set' field it True.
And make sure you only create the dialog once (or else be sure to destroy it in the cancel and ok callbacks).
Andriy Konoval
Unexpeted behaviour of togglebutton
Try this code. If something be wrong, let me know.
#include
#include
#include
#include
#include
Widget top;
void Exit(Widget w, XtPointer client, XtPointer call)
{
exit(0);
}
Widget
XmCreateFileSelectorDialog(
Widget parent,
char *name,
ArgList arglist,
Cardinal argcount)
{
return XmeCreateClassDialog (xmFileSelectionBoxWidgetClass,
parent, name, arglist, argcount);
}
void cs_ok_cb(Widget w, XtPointer client, XtPointer call)
{
}
void call_cs_cb(Widget w, XtPointer client, XtPointer call)
{
Arg args[5];
Cardinal argcnt;
Widget fileselector;
argcnt=0;
fileselector = XmCreateFileSelectorDialog(top, "fileSelector", args, argcnt);
XtAddCallback(fileselector, XmNokCallback, cs_ok_cb, client);
XtManageChild(fileselector);
}
int
main(int argc, char **argv)
{
Arg args[5];
Cardinal argcnt;
Widget big_pane, call_cs_pb, fileframe, call_cs_pb2;
XtAppContext app;
XmString xmstring;
Colormap default_map;
XColor the_color;
unsigned long mask;
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
argcnt = 0;
XtSetArg(args[argcnt], XmNtitle, "File Selector Demo"); argcnt++;
XtSetArg(args[argcnt], XmNallowShellResize, True); argcnt++;
top = XtOpenApplication( &app, "FS", NULL, 0, &argc, argv, NULL, applicationShellWidgetClass,
args, argcnt);
default_map = DefaultColormapOfScreen(XtScreen(top));
/* big pane */
argcnt = 0;
XtSetArg(args[argcnt], XmNorientation, XmHORIZONTAL); argcnt++;
big_pane = XtCreateManagedWidget("bull",xmRowColumnWidgetClass, top, args, argcnt);
call_cs_pb = XtVaCreateManagedWidget("fileSelector",
xmToggleButtonWidgetClass,
big_pane,
NULL);
call_cs_pb2 = XtVaCreateManagedWidget("fileSelector2",
xmToggleButtonWidgetClass,
big_pane,
NULL);
XtAddCallback(call_cs_pb, XmNarmCallback, call_cs_cb, fileframe);
XtRealizeWidget(top);
XtAppMainLoop(app);
return(0);
}
fredk
Re: Unexpeted behaviour of togglebutton
I cannot duplicate your problem.
However, why are you posting the dialog from an XmNarmCallback? You should be using the XmNvalueChangedCallback, and posting the dialog if the 'set' field it True.
And make sure you only create the dialog once (or else be sure to destroy it in the cancel and ok callbacks).
--
Fred