thundergnat has asked for the wisdom of the Perl Monks concerning the following question:
I have several utilities based on scrolled text widgets. I have been trying to add a "drag handle" to the lower right of the window to ease resizing (like nearly all windowed applications have) but have been having trouble getting the cursor I would prefer. X11/cursorfont.h doesn't seem to have "resize_nwse" (the diagonal double arrow you see if you place your cursor over the resize pad down in the lower right corner). Instead, I seem to be stuck with the "sizing" cursor, which isn't really what I want, and I havn't been able to figure out how to access the window managers native one. (Almost all window managers have such a beast.)
Any ideas?
Here's a sample script showing what I am trying to do.
Put your cursor at the lower right corner to see the cursor I want, then over the "drag handle" to see what I have.
#!/usr/local/bin/perl use strict; use warnings; use Tk; my $top = MainWindow->new; my $text = $top->Scrolled('Text', -scrollbars => 'se', )->pack( -expand => 1, -fill => 'both' ); my ($mouse_x, $mouse_y); my $corner = $text->Subwidget('corner'); my $corner_label = $corner->Label( -image => $top->Photo( -format=>'gif', -data => 'R0lGODlhDAAMALMAAISChNTSzPz+/AAAAOAAyukAwRIA4wAAd8oA +0MEAe+MTYHcAANAGgnsAAGAA AAAAACH5BAAAAAAALAAAAAAMAAwAAwQfMMg5BaDYXiw178AlcJ6V +hYFXoSoosm7KvrR8zfXHRQA7' ), )->pack(-side => 'bottom', -anchor => 'se'); # I actually want a resize_nwse cursor, but this was the closest I cou +ld find $corner_label->bind('<Enter>' => sub {$corner->configure(-cursor => 's +izing')}); $corner_label->bind('<1>' => sub { ($mouse_x, $mouse_y) = ($top->pointerx, $top->pointery) }); $corner_label->bind('<B1-Motion>' => sub { my $x = $top->width - $mouse_x + $top->pointerx; my $y = $top->height - $mouse_y + $top->pointery; ($mouse_x, $mouse_y) = ($top->pointerx, $top->pointery); $top->geometry($x.'x'.$y); }); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/Tk resizing cursor?
by GrandFather (Saint) on Nov 02, 2005 at 17:59 UTC | |
by thundergnat (Deacon) on Nov 02, 2005 at 18:10 UTC | |
by GrandFather (Saint) on Nov 02, 2005 at 20:35 UTC | |
by thundergnat (Deacon) on Nov 03, 2005 at 00:10 UTC | |
|
Re: Perl/Tk resizing cursor?
by rcseege (Pilgrim) on Nov 02, 2005 at 21:23 UTC | |
by thundergnat (Deacon) on Nov 03, 2005 at 00:12 UTC | |
|
Re: Perl/Tk resizing cursor?
by eddietheperl (Initiate) on Nov 02, 2005 at 18:04 UTC | |
by NateTut (Deacon) on Nov 02, 2005 at 18:26 UTC |