Re: [gtk-list] Re: Preventing Up/Down Arrows from Moving Focus



In message <Pine.BSF.4.02A.9905272020340.16732-100000@zirx.pair.com>you write:
>
>On Thu, 27 May 1999, Melissa Danforth wrote:
>> Within an entry widget, pressing the up/down arrow keys causes the focus
>> to shift to the next/previous widget. I have an application where I do not
>> want this to occur. I noticed that within the text widget, using the up
>> and down arrow keys does not cause the focus to move, but even after looking
>> at the source, I cannot find how it does that.
>> 
>> How does one prevent the up/down arrows from shifting the focus? 
>> For my application, it is probably sufficient to just allow the mouse
>> to change the focus.
>> 
>

This is the simplest way I know. Here's the code from my current
project that handles this. Its in C++, but it should be reasonably
clear what's going on:

gint 
MotionFeedback::pixwin_key_press_event (GdkEventKey *ev) 

{
        gint retval = FALSE;

	/* .... */

	switch (ev->keyval) {
	case GDK_Page_Up:
	        retval = TRUE;
		/* ... do something ... */

		break;

	case GDK_Page_Down:
	        retval = TRUE;
		/* ... do something ... */
		break;

	case GDK_Up:
	        retval = TRUE;
		/* ... do something ... */
		break;

	case GDK_Down:
	        retval = TRUE;
		/* ... do something ... */
		break;

	case GDK_Home:
	        retval = TRUE;
		/* ... do something ... */
		break;

	case GDK_End:
	        retval = TRUE;
		/* ... do something ... */
		break;
	}
	
	if (retval) {
		gtk_signal_emit_stop_by_name (GTK_OBJECT(pixwin.gtkobj()),
					      "key_press_event");
	}

	return retval;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]