GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 21, 2014 8:46 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Fake an event.
PostPosted: Wed Feb 20, 2008 9:36 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
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:
#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!

_________________
http://killocan.freezope.org


Top
 Profile  
 
 Post subject: my mistake :D
PostPosted: Thu Feb 21, 2008 2:14 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
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:
    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 ;)

_________________
http://killocan.freezope.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group