GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fake an event.

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
killocan
Familiar Face


Joined: 23 Jan 2008
Posts: 18
Location: Brasil

PostPosted: Wed Feb 20, 2008 9:36 pm    Post subject: Fake an event. Reply with quote

hey folks :D i'm trying to simulate the GDK_ENTER_NOTIFY event to force entry to show the tooltip. I set up a GdkEventCrossing structure and send using gdk_event_put, but my entry do not show the tooltip. My test code is like this one:

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

#include <stdio.h>
#include <gtk/gtk.h>
#include <gtk/gtktooltip.h>

GtkWidget*      window;
GtkWidget*      fixed;   
GtkWidget*      entry;
GtkWidget*      button;
GtkTooltips*     tooltip;
GdkEventCrossing *e;

void Callback(GtkWidget* poWidget, gpointer oThis)
    {
    gdk_event_put((GdkEvent *) e);
    }

int main (int argc, char** argv)
{
    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_size_request (window, 800, 600);

    fixed = gtk_fixed_new ();
    gtk_widget_set_size_request (fixed, 800, 600);

    entry = gtk_entry_new ();
    gtk_widget_set_size_request (entry, 50, 50);

    tooltip = gtk_tooltips_new ();
    gtk_tooltips_set_tip (tooltip, entry, "TESTE TOOLTIP", NULL);

    e = (gpointer)gdk_event_new(GDK_ENTER_NOTIFY);
    e->window = entry->window;
    e->send_event = 1;               /* True if we're sending event. */
   
e->subwindow = entry->window;
    e->time = GDK_CURRENT_TIME;
    e->x = 0.0;
    e->y = 0.0;
    e->x_root = 0.0;
    e->y_root = 0.0;
    e->mode = GDK_CROSSING_NORMAL;
    e->detail = GDK_NOTIFY_ANCESTOR;
    e->focus = TRUE;                 /* Focus. */
   
e->state = 0;                    /* Key modifiers. */

   
button = gtk_button_new_with_label ("AAA");

    g_signal_connect (window, "destroy",
            G_CALLBACK (gtk_main_quit), NULL);

    g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(Callback), NULL);

    gtk_fixed_put (GTK_FIXED(fixed), button, 20, 20);
    gtk_fixed_put (GTK_FIXED(fixed), entry, 100,100);
    gtk_container_add (GTK_CONTAINER(window), fixed);

    gtk_widget_show_all (window);

    //gtk_signal_emit_by_name(GTK_OBJECT(entry),"enter-notify-event",e); doesn't work either.

   
gtk_main ();

    return 0;
}


My gtk version do not suport keyboard tooltip event inside entry widgets, and i'm not allowed to use another gtk version :(

Thanks for all!
Back to top
killocan
Familiar Face


Joined: 23 Jan 2008
Posts: 18
Location: Brasil

PostPosted: Thu Feb 21, 2008 2:14 pm    Post subject: my mistake :D Reply with quote

Hey, sorry for this, but all i have to do is move the struct initialization to a place where the entry already has a parent, i.e: after:

Code: (C)
1
2
3
4
5

    gtk_fixed_put (GTK_FIXED(fixed), entry, 100,100);
    gtk_container_add (GTK_CONTAINER(window), fixed);
    gtk_widget_show_all (window);


... Thanks for all anyway ;)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP