gtkvalagenie

Hiding transition in Gtk


This is a continuation of a previous question on the Gtk.SearchEntry widget.

In that question I manage to reveal the entry widget upon clicking in the icon, now I want the widget to disappear after it loses focus.

The approach used now was with:

    search_entry.icon_release.connect (hide_search)

And defined hide_search as:

def hide_search()
    search_button_revealer.set_reveal = true
    search_entry_revealer.set_reveal = false
    show_all()

However, this does not solve the problem. The entire code can be found here.


Solution

  • You seem to be grabbing the wrong signal. The one you have is for when you click the button inside the entry while the one you need is focus_out_event, this is the vala code that makes what you want :)

    search_entry.focus_out_event.connect (() => {
        // Make sure the entry is empty so you don't 
        // close it out on the user
        if (search_entry.get_text () == "") {
            hide_search ();
        }
    
        return false;
    });