views:

143

answers:

1

Hi Guys,

Pretty straight foward question, I have a GtkEntry widget that i want to set to be editable. I know the function i should use is:

gtk_editable_set_editable

But i dont know how to make it take a GtkEntry widget as an arguement

Can anyone help me?

Regards

Paul

UPDATE:

Ok, so here is the code im using:

GtkWidget *TextEntry;
TextEntry = gtk_entry_new();
gtk_entry_set_visibility(GTK_ENTRY(TextEntry), TRUE);
gtk_entry_set_editable(GTK_ENTRY(TextEntry), TRUE);
gtk_entry_set_overwrite_mode(GTK_ENTRY(TextEntry), TRUE);
gtk_widget_set_can_focus(GTK_WIDGET(TextEntry), TRUE);
gtk_widget_grab_focus(TextEntry);
panel_applet_request_focus(applet, 10);
gtk_container_add (GTK_CONTAINER (applet), TextEntry);

gtk_widget_show_all (GTK_WIDGET (applet));

So far as getting keyboard focus, i think i need the panel_applet_request_focus function. It requires that i pass it the applet in question and the timestamp of the event triggering the window focus

Im not sure what to put in for the timestamp. I compiled the code as above and i still cant get keyboard focus when i click the applet.

+1  A: 

Do the following:

GtkWidget* entry = gtk_entry_new();
gtk_entry_set_editable(GTK_ENTRY(entry), TRUE);

Welcome to the world of GObject :)

Note that if you were using gtk_editable, you need to do:

gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE);
SB
@SB: Tried that, resulting in the following error: error: cannot convert ‘GtkEntry*’ to ‘GtkEditable*’ for argument ‘1’ to ‘void gtk_editable_set_editable(GtkEditable*, gboolean)’
paultop6
That's odd. The docs indicate that GtkEntry implements GtkEditable. Did you try the deprecated gtk_entry_set_editable to see what happens?
SB
this is daft, but what do you mean by depreciated?
paultop6
Deprecated means the API shouldn't be used anymore in favor of another. http://library.gnome.org/devel/gtk/stable/GtkEntry.html#gtk-entry-set-editable is what I'm talking about. Try the first suggestion I have in my answer using gtk_entry_set_editable as opposed to gtk_editable_set_editable.
SB
Ok i used the depreciated one and it compiled fine. It would appear to be something else. Basically when i click on the text Box i want to be able to type in characters and such, but its not picking it up. Thank for you help SB.
paultop6
GtkEntry and setting it editable is exactly what you want. You'll need to post code so I can see your issue.
SB
@SB: Code posted
paultop6
You may want to look at gtk_widget_get_events () and gtk_widget_add_events () to make sure the events mask is correct. http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-add-eventsAlso can you post the code that didn't work with gtk_editable_set_editable?
SB
@paultop6: That's "deprecated", there's no 'i' in there.
unwind