Search code examples
perlgtkglade

Gtk Perl : remove default text in Text Entry without using a placeholder


While I am aware that set_placeholder_text("I am the placeholder") will solve my problem, this feature is only available from Gtk+ 3.2 onwards.

I would like to know the simplest method to remove the default text from a Text Entry box when the user clicks on it.


Solution

  • Using the 'focus-in-event' signal is a satisfactory solution here. In the callback, set the text in the Text Entry box to "" so that it is cleared when clicked on (i.e., when the Text Entry box gets focus).

    https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-focus