Re: Events and Signals


I tryed to change event.keyval to GDK_Left(left key arrow) to test it. But
it doesn´t work.
My question is if is possible to sent key events (keys arrows) to move on a
GtkCList using gtk_event_put()?
Remember that I recieve network event and I´d like to move on GtkCList and
select items on it.

Thanks a lot and regards

Ariel Antonio Fritz

Ariel Fritz wrote:

Do you have some example about it?

The sample coming attached. Its very simple, read this to use/modify it
for your needs:



/* compile with gcc -Wall `pkg-config --cflags --libs` event-put.c -o

This prog will set a characters [0-9] into GtkEntry with 1 sec period.

NOTE: there're many fields in GdkEventKey structure, this example shows
the simpliest

#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

static gboolean event_put(GtkWidget *entry)
GdkEventKey event;

memset(&event, 0, sizeof(event)); /* clear the structure */

event.time = GDK_CURRENT_TIME; /* current timestamp */
event.type = GDK_KEY_PRESS;
event.send_event = TRUE; /* indicating that this event is synthetic */
event.keyval = 0x30 + rand()%10; /* generating character [0-9] */
event.window = entry->window; /* application window, will be non-zero
after widget get realized */

if (event.window) /* posting event if widget is realized */

return TRUE;

int main(int argc, char **argv)
GtkWidget *window;
GtkWidget *entry;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(window), 4);
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0);

entry = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(window), entry);

gtk_timeout_add(1000, (GtkFunction)event_put, window); /* setting callback
with 1s period */


return 0;

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