How to catch mouse click event on a disabled button - Motif
This is a discussion on How to catch mouse click event on a disabled button - Motif ; Hi all,
I want to handle mouse click message on disabled button.
I have written some thing like this,
Widget top_wid, button;
XtAppContext app;
top_wid = XtVaAppInitialize(&app, "Push", NULL, 0,
&argc, argv, NULL, NULL);
button = XmCreatePushButton(top_wid, "Push_me", NULL, 0);
...
-
How to catch mouse click event on a disabled button
Hi all,
I want to handle mouse click message on disabled button.
I have written some thing like this,
Widget top_wid, button;
XtAppContext app;
top_wid = XtVaAppInitialize(&app, "Push", NULL, 0,
&argc, argv, NULL, NULL);
button = XmCreatePushButton(top_wid, "Push_me", NULL, 0);
XtSetSensitive(button,FALSE);
/* tell Xt to manage button */
XtManageChild(button);
/* attach fn to widget */
XtAddCallback(button, XmNactivateCallback, pushed_fn, NULL);
XtRealizeWidget(top_wid); /* display widget hierarchy */
XtAppMainLoop(app); /* enter processing loop */
}
void pushed_fn(Widget w, XtPointer client_data,
XmPushButtonCallbackStruct *cbs)
{
printf("Don't Push Me!!\n");
}
But it doesnt work. Please some body explain me how to do it.
Thanks in Advance,
SeemaRao
-
Re: How to catch mouse click event on a disabled button
seema_coma@yahoo.co.in wrote:
> Hi all,
> I want to handle mouse click message on disabled button.
> I have written some thing like this,
>
> Widget top_wid, button;
> XtAppContext app;
> top_wid = XtVaAppInitialize(&app, "Push", NULL, 0,
> &argc, argv, NULL, NULL);
> button = XmCreatePushButton(top_wid, "Push_me", NULL, 0);
> XtSetSensitive(button,FALSE);
> /* tell Xt to manage button */
> XtManageChild(button);
> /* attach fn to widget */
> XtAddCallback(button, XmNactivateCallback, pushed_fn, NULL);
>
> XtRealizeWidget(top_wid); /* display widget hierarchy */
> XtAppMainLoop(app); /* enter processing loop */
> }
>
> void pushed_fn(Widget w, XtPointer client_data,
> XmPushButtonCallbackStruct *cbs)
> {
> printf("Don't Push Me!!\n");
> }
>
> But it doesnt work. Please some body explain me how to do it.
Of course it doesnt work. The essence of SetSensitive(FALSE) is that it
*wont* respond to clicks; the grayed-out look is just to *show* the
unresponsiveness. It is never a good idea to change a standard
look-and-feel, unless you have a *very* good reason, and you didnt give any.
One good reason to have an unsensitive widget respond to some input is
to display the reason why it is insensitive. I suggest you look at
LITECLUE in the XLT library at www.lesstif.org, which allows you to use
tooltips to display info about a widget even insensitive. Its not in the
table of wodgets on the web page, but it is in the CVS version.
>
> Thanks in Advance,
> SeemaRao
>
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux@mediaxim.be
Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
-
Re: How to catch mouse click event on a disabled button
You need to manage the disabled state with your own visual (a different
color, etc) and not XtSetSensitive. Then test for that state in the
callback to see whether it's valid or not.