Gtk Treeview query tooltip - hide if blank for cell

I have setup a tooltip for a gtkview (liststore) in gtk3-perl
It all works fine except if there is no tooltip text an ugly black rectangle shows up. Is there a way to hide this.

	return 1;

sub encode_gui_tooltip {
	my ($sopts)=@_;
	my ($view,$xpos,$ypos,$key,$tooltip)=
	my ($bin_x, $bin_y) = $view->convert_widget_to_bin_window_coords($xpos, $ypos);
		my @path = $view->get_path_at_pos($bin_x,$bin_y);
		my ($row,$colno);
		if ($path[0]){

		if ($path[1]){
				#elsif ($colno==3){
					my $option;
				if (!($option )){
				 $view->set_tooltip_cell($tooltip, $path[0], $path[1])

			if ($actions{$row}->{$colno}->{cmd}){
			else {
				no warnings ;
				#my $tooltip=undef;
				#$view->set_tooltip_cell($tooltip, $path[0], $path[1]);
				return 0

As can be see I’ve tried various approaches so far with no success. Setting tooltip to undef works but spews out loads of messages from Glib::Introspection
unhandled exception in callback:
*** undef is not of type Gtk3::Tooltip at /usr/lib64/perl5/vendor_perl/Glib/Object/ line 67.
*** ignoring at /usr/share/perl5/vendor_perl/ line 572.

Returning FALSE should hide the tooltip. You can also use an empty string. If neither of these work, then there’s something wrong with either GTK or with your code.

You cannot set $tooltip to undef because you’re literally overwriting data that does not belong to you; the Tooltip object is owned by the widget.

Thanks, I had the return in the query-tooltip callback, while returning 0 in the callback function.
Removing that and putting return values as appropriate fixed it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.