Motif Toolbar? MouseOver effects?

This is obvious. A toolbar with buttons that actually have mouseover effects (please do not suggest using a RowColumn on PushButtons). For reference see the XmEnhancedButton widget supplied in gVim (Motif version) at www.vim.org

In general, mouseover effects (sometimes called 'hot-tracking') are a very Good Thing to have, even in menus. Can I enable this via some resources in OM 2.2.3, or do I have to wait for OM 200.5000?

It is kind of like having a hybrid focus policy. The *keyboard* focus remains click-to-type, but the *mouse* focus is focus-follows-mouse. I am not sure this can be done with the current unified 'input focus' concept.


Andriy Konoval

Andriy Konoval's picture

Motif Toolbar? MouseOver effects?

You can do this via translations. This feature is available for ages in Xt, so you don't need to wait new version of OpenMotif :-)
Here is a sample demonstrating using Enter and Leave translations, I hope it is what you need.

#include <Xm/MainW.h><br />
#include <Xm/PushB.h><br />
main (int argc, char *argv[])<br />
{<br />
	Widget toplevel, main_w, pb;<br />
	XtAppContext app;<br />
	void ren (Widget, XEvent *, String *, Cardinal *);<br />
	XtActionsRec actions;<br />
	Arg args[10];<br />
	int n;</p>
<p>	String translations =<br />
						"#override \n\<br />
					   	<Enter>:ren( enter)\n\<br />
                       	<Leave>:ren( leave)	";</p>
<p>	XtSetLanguageProc (NULL, NULL, NULL);<br />
	toplevel = XtVaOpenApplication (&app, "Demos", NULL, 0, &argc, argv, NULL,<br />
			sessionShellWidgetClass, NULL);</p>
<p>	n = 0;<br />
	XtSetArg (args[n], XmNscrollingPolicy, XmAUTOMATIC); n++;<br />
	main_w = XmCreateMainWindow (toplevel, "main_w", args, n);</p>
<p>	actions.string = "ren";<br />
	actions.proc = ren;<br />
	XtAppAddActions (app, &actions, 1);</p>
<p>	n = 0;<br />
	XtSetArg (args[n], XmNtranslations, XtParseTranslationTable (translations)); n++;<br />
	pb = XmCreatePushButton (main_w, "leave",args, n);<br />
	XtManageChild (pb);<br />
	XtManageChild (main_w);<br />
	XtRealizeWidget (toplevel);<br />
	XtAppMainLoop (app);<br />
}</p>
<p>void ren (Widget widget, XEvent *event, String *args, Cardinal *num_args)<br />
{<br />
	XmString xms;<br />
	if (*num_args != 1)<br />
		XtError ("Wrong number of args!");<br />
	if (!strcmp (args[0], "enter"))<br />
		xms = XmStringCreateLocalized("enter");<br />
	else<br />
		xms = XmStringCreateLocalized("leave");<br />
	XtVaSetValues(widget, XmNlabelString, xms, NULL);<br />
}