Re: set tooltip on treeview cell/row?



I want to display a tooltip if the mouse hovers over a treeview cell?
any ideas? There is no treecolumn attribute to get a tooltip string from
a column.

There is no shortcut to achieve this, but I think its possible.

# Trap the treeview motion-notify-event. This will tell you when 
# there is a mouse-over on a cell
$tree_view->signal_connect('motion-notify-event' =>
  sub {        
    my ($self, $event) = @_;
    my ($path, $column, $cell_x, $cell_y) = $self->get_path_at_pos
($event->x, $event->y);
    
    # Now you know the path and the column to the cell.
    # Lookup an external datastructure where you have already
    # stored your tooltip text.
    my $tooltip_text = $tooltip_hash->{$path}->{$column};
    
    # Now we'll create a fake (or handmade) tooltip
    # Please read
http://live.gnome.org/GTK2_2dPerl_2fRecipes#head-57cc99de5899b7363abb59f9c4978e4d35cb0fc6
    # That recipe will show you how to build your own tooltip window
    
    ......
  }
}


I am doing something similar in Gtk2::Ex::TreeMaker
http://cvs.sourceforge.net/viewcvs.py/gtk2-perl-ex/Gtk2-Ex/TreeMaker/lib/Gtk2/Ex/TreeMaker.pm?rev=1.21&view=log

My need was to change the cursor based on a setting called
'hyperlinked' which is populated at a cell level in the treeview. In
the code look at the section that says
"       # If the cell is hyperlinked, then change the mouse pointer to something else
        # This will give a visual feedback to the user that he should click
on the cell"

Its a bit convoluted but it worked for me. I think it'll work for you too.

Regards,

Ofey.



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