Re: gtk_text_entry



On Thu, 2005-05-19 at 23:17, srinivas wrote:
  thanks for reply to my queries, still i am facing the same problem,
i can't get the text entered in to the gtk_text_entry widget. how can i
get the text entered in to the text_entry widget. is any event signal i
have to give to text_entry widget.

gtk_entry_get_text()

see:
http://developer.gnome.org/doc/API/2.0/gtk/GtkEntry.html#gtk-entry-get-text

As far as signals go, the entry will emit a "changed" signal whenever
the text is altered and an "activate" signal if the user presses Enter
while the entry is selected. Example:

GtkWidget *entry = gtk_entry_new();
g_signal_connect(G_OBJECT(entry),"changed",G_CALLBACK(onChanged),NULL);
g_signal_connect(G_OBJECT(entry),"activate",G_CALLBACK(onEnter),NULL);
gtk_widget_show(GTK_WIDGET(data->entry));

Then the callbacks:

gboolean onEnter(GtkWidget *widget, gpointer *data) {
    /* called when user presses Enter */
    const gchar *s = gtk_entry_get_text(data->entry);
    /* Do something with the text here,
       then to clear the entry do... */
    gtk_entry_set_text(data->entry,"");
    return TRUE;
}

gboolean onChanged(GtkWidget *widget, gpointer *data) {
    /* called when entry contents change */
    return TRUE;
}






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