Re: Gtk::Tooltip and Gtk::TreeView



Thank you for the help!
I finally solved it by adding this just before return true to the tooltip query signal handler:

get_tree_view().set_tooltip_row(tooltip, path);

And it worked as expected!
Greetings
Carlos


De: José Alburquerque <jaalburquerque gmail com>
Para: Carlos Lopez Gonzalez <carloslopezgonzalez yahoo es>
CC: "gtkmm-list gnome org" <gtkmm-list gnome org>
Enviado: martes 8 de noviembre de 2011 21:00
Asunto: Re: Gtk::Tooltip and Gtk::TreeView

On Tue, 2011-11-08 at 18:38 +0000, Carlos Lopez Gonzalez wrote:
> Hi!
> I've been working on add tooltips for a treeview. Those are the
> relevant sections of code that performs the tooltips:
>
>
> class LayerTree : public Gtk::Table
> {
>    // The rest of the class is omited
> private:
>    Gtk::TreeView* param_tree_view_;
>    bool on_param_tree_view_query_tooltip(int x, int y, bool
> keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
> public:
>    Gtk::TreeView& get_param_tree_view() { return *param_tree_view_; }
> };
>
>
> LayerTree::LayerTree()
> {
>    param_tree_view_=new Gtk::TreeView;
>    // Here is the the code to add columns and model data to
> param_tree_view_
>
> get_param_tree_view().signal_query_tooltip().connect(sigc::mem_fun(*this, &studio::LayerTree::on_param_tree_view_query_tooltip));
>    get_param_tree_view().set_has_tooltip();
> }
>
> LayerTree::on_param_tree_view_query_tooltip(int x, int y,
> bool /*keyboard_tooltip*/, const Glib::RefPtr<Gtk::Tooltip>& tooltip)
> {
>    Gtk::TreeModel::Path path;
>    Gtk::TreeViewColumn *column;
>    int cell_x, cell_y;
>    int bx, by;
>    get_param_tree_view().convert_widget_to_bin_window_coords(x, y,
> bx, by);
>    if(!get_param_tree_view().get_path_at_pos(bx, by, path, column,
> cell_x,cell_y))
>        return false;
>    Gtk::TreeIter
> iter(get_param_tree_view().get_model()->get_iter(path));
>    if(!iter)
>        return false;
>    Gtk::TreeRow row = *(iter);
>    Glib::ustring tooltip_string(row[param_model.tooltip]);
>    if(tooltip_string.empty())
>        return false;
>    tooltip->set_text(tooltip_string);
>    return true;
> }
>
>
> The result of this code is shown on this video:
>
> http://www.youtube.com/watch?v=UQkP3z6dG7Y
> As you can see, the tooltip window is shown in the place where the
> timeout expired when the mouse hovered on the widget and not where the
> mouse is when the text is changed.
> How do I do to place the tooltip near the mouse?

See the Gtk::Tooltip::set_tip_area() docs:

http://developer.gnome.org/gtkmm/unstable/classGtk_1_1Tooltip.html#a197701484426a19f1dee98411e3d3878

> Thanks!
> Carlos
>
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list

--
José






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