Subject: | Dosn't work on Canvas widgets |
Date: | Tue, 9 Sep 2008 11:46:06 -0400 |
To: | bug-Gtk2-Ex-Xor [...] rt.cpan.org |
From: | zentara <zentara1 [...] sbcglobal.net> |
Hi,
I tried to setup the Crosshairs on a Gnome2::Canvas and a Goo::Canvas,
but the lines and cursor are invisible. I remember in some similar maillist
emails you said the graphic's context wasn't setup. Do you know a work-around
for canvases?
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2 '-init';
use Gnome2::Canvas;
use Gtk2::Ex::CrossHair;
my $mw = Gtk2::Window->new('toplevel');
$mw->signal_connect (destroy => sub { Gtk2->main_quit });
my $vbox = Gtk2::VBox->new(0,0);
$mw->add ($vbox);
my $canvas = Gnome2::Canvas->new();
my $white = Gtk2::Gdk::Color->new (0xFFFF,0xFFFF,0xFFFF);
my $green = Gtk2::Gdk::Color->new (0x0000,0xFFFF,0x0000);
my $black = Gtk2::Gdk::Color->new (0x0000,0x0000,0x0000);
$canvas->modify_bg('normal',$white);
$canvas->modify_fg('active',$green);
$canvas->modify_base('active',$green);
$mw->set_default_size( 400, 300 );
$vbox->pack_start ($canvas, 1,1,1);
my $status = Gtk2::Label->new;
$vbox->pack_start ($status, 0,1,0);
my $cross = Gtk2::Ex::CrossHair->new (widget => $canvas,
#foreground => '#00ff00',
foreground => $green,
);
$cross->signal_connect (moved => sub {
my ($cross, $widget, $x, $y) = @_;
if (defined $x) {
$status->set_text ("now at $x,$y");
} else {
$status->set_text ('');
}
});
$canvas->add_events ('button-press-mask');
$canvas->signal_connect (button_press_event => sub {
my ($canvas, $event) = @_;
$cross->start ($event);
return 0;
});
$mw->show_all;
Gtk2->main;
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html