[comp.windows.x] novice question - flashing Athena Widgets?

neighorn@qiclab.UUCP (Steven C. Neighorn) (11/13/89)

This will probably get me thrown out of the X programmer's club, but if
some kind soul could give this underfed no-sleep programmer the answer,
I would be eternally grateful...

What is the preferred method for changing the set() and unset() actions
for a commandWidget? I would like to prevent the default selection flash
when the pointer button is pressed and released.

Also, is there a nice way to flash another currently activated
commandWidget interior? (imagine, if you will, a bunch of commandWidgets
on the screen - the user moves the pointer to one of the widgets and
presses the mouse button, but instead of a flash in that widget another
widget that is not selected flashes.)

I know these are *really stoopid* questions, but if I could get just a
little help on using the various actions in the commandWidget, I would
really appreciate it.

Thank you for your indulgence, and remember we all started somewhere :-).

-- 
Steven C. Neighorn           !tektronix!{psueea,nosun,ogccse}!qiclab!neighorn
Sun Microsystems, Inc.      "Where we DESIGN the Star Fighters that defend the
9900 SW Greenburg Road #240     frontier against Xur and the Ko-dan Armada"
Portland, Oregon 97223          work: (503) 684-9001 / home: (503) 641-3469

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (11/14/89)

> What is the preferred method for changing the set() and unset() actions
> for a commandWidget? I would like to prevent the default selection flash
> when the pointer button is pressed and released.

Try adding this to your resource database:

*Command.translations:	#replace 		\n\
     <EnterWindow>:     highlight()             \n\
     <LeaveWindow>:     reset()                 \n\
     <Btn1Down>:        InvertButton()          \n\
     <Btn1Up>:          InvertButton() notify()

This will remove the invert semantics from the Command widget.  And call
the application defined action InvertButton.  This action can invert
the other button on button down, and flip it back on button up.

*** Don't forget to register this action with XtAppAddActions. ***

Here is one possible implementation of InvertButton, I just threw this
together so if it doesn't build...

/* ARGUSED */
void
InvertButton(w, event, params, num_params)
Widget w;			/* We don't use any of these arguements. */
XEvent * event;
String * params;
Cardinal * num_params;
{
	Widget command;
	Arg args[2];
	Cardinal num_args;
	Pixel fg, bg;

	/* Somehow get the command widget to highlight. */

	/*
 	 * Get the foreground and background colors. 
	 */

	num_args = 0;
	XtSetArg(args[num_args], XtNforeground, &fg); num_args++
	XtSetArg(args[num_args], XtNbackground, &bg); num_args++
	XtGetValues(command, args, num_args);

	/*
 	 * Swap them.
 	 */

	num_args = 0;
	XtSetArg(args[num_args], XtNforeground, bg); num_args++
	XtSetArg(args[num_args], XtNbackground, fg); num_args++
	XtSetValues(command, args, num_args);
}


I hope this is enough to get you moving again.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213