XmToggleButton problem

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

Questions about motif? Contact us

3 posts / 0 new
Last post
XmToggleButton problem

Submitted by Anonymous on Tue, 04/02/2002 - 17:32. Developers
I have a problem with XmToggleButton that works fine in Lesstif and older versions of Motif.

I have a button that resets itself after it has been clicked. It does this by calling XmToggleButtonSetState(,0,FALSE) from inside its value changed callback. This changes the visual appearance and logical state of the button fine, but then the button ignores mouse clicks. I have found no way to awaken it via software. The only way to get it working again is to click on any other toggle button with the mouse.

I would really appreciate some help with working around this new Motif "feature" without having to change my user interface.

Thanks in advance.

ICS_support

It`s usually considered poor form to change a widget in its own callback -- in part because it makes for confusing code, in part because it can lead to infinite loops, and in part because most widgets aren`t written well-enough to be able to handle such changes. (I`m not sure what Xt says on the matter, but the practice is deprecated.)

The usual solution to such situations doesn`t involve large changes to your code. In your callback, instead of making the call directly to XmToggleButtonSetState(), set a very short (1ms) timer, using the widget value and anything else you need as client_data. Then, in the timer function, make that call. This "trick" works because the timer will be called once Xt has unraveled back to the application level, without being in the widget`s internal callbacks or internal code.

Anonymous

Thanks for your help.--

Actually, I had thought of that and tried the timer already, but the problem remains. Even when I reset the button state from the callback, it dies. I just reproduced that test again to check, and it still didn`t work. Any other suggestions? I`ll try anything.

My code was

(in the callback)
XtAppAddTimeOut(the_app, 1, (XtTimerCallbackProc)TriggerChangedProc, pe_win);

void PEventControlWindowTriggerChangedProc(PEventControlWindow *pe_win)
{

int oldFlag = pe_win->mTriggerFlag;
pe_win->mTriggerFlag = pe_win->GetData()->trigger_flag; // save new trigger type
// unset old radio
XmToggleButtonSetState(pe_win->trigger_radio[oldFlag], 0, FALSE);
// set new radio
XmToggleButtonSetState(pe_win->trigger_radio[pe_win->mTriggerFlag], 1, FALSE);
pe_win->UpdateTriggerText(); // update the text according to the new trigger setting
}