GTK+ (2.0) - signal “clicked” on GtkEntry?

安稳与你 提交于 2019-12-07 11:30:10

问题


I'm testing some signals with GTK+ 2.0. I'm looking for a way to get a signal emitted when I click on a GtkEntry.

if (widgets_info[i].action & IG_INPUT)
    {
      widget->frame[i] = gtk_entry_new_with_max_length(MAX_INPUT_LENGTH);
      gtk_entry_set_text(widget->frame[i], widgets_info[i].text);
      catch_signal(widget->frame[i], MY_SIGNAL, &change_entry, widget);
    }

I have a pre-selected text in my entry (widgets_info[i].text) and i want this text to disappear if the user click on my GtkEntry.

Does someone know what is this signal?

(Sorry for my English)


回答1:


Try focus-in-event, note that you must enable focus-tracking as described in the documentation.




回答2:


The button-press-event signal should do what you need: http://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-button-press-event

However, in GTK+ 3, GtkEntry now supports this idea of placeholder text, so you don't need to implement it yourself: http://developer.gnome.org/gtk3/stable/GtkEntry.html#gtk-entry-set-placeholder-text



来源:https://stackoverflow.com/questions/10173190/gtk-2-0-signal-clicked-on-gtkentry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!