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;
UPDATE: I should have mentioned, I would like to do this cross-platform if possible. I have users running every version of Windows from Win95 up, several different distros of Linux and MAC OSX, so I don't want to lock into a specific platform if I can avoid it.

Replies are listed 'Best First'.
Re: Perl/Tk resizing cursor?
by GrandFather (Saint) on Nov 02, 2005 at 17:59 UTC

    On Windows XP I get a big fat NWSE style cursor (but not the standard one) with the mouse over the resize pad in the bottom right corner of the window. Am I seeing something that you are not?


    Perl is Huffman encoded by design.

      No, you are seeing exactly what I'm seeing. Like I said, the best choice I could find seemed to be the 'sizing' cursor which was what I used, but what I really want is to use the 'standard' resize cursor if I possibly can.

        Under Windows size_nw_se does it. See this link.


        Perl is Huffman encoded by design.
Re: Perl/Tk resizing cursor?
by rcseege (Pilgrim) on Nov 02, 2005 at 21:23 UTC

    I haven't looked at it in a while, but does Tk::CornerBox (Part of Tk::DKW) do what you're looking for? Seems like it might fit the bill.

    Rob

      Ah. This looks like what I need. My CPAN search fu is apparantly not up to snuff. Thanks.

Re: Perl/Tk resizing cursor?
by eddietheperl (Initiate) on Nov 02, 2005 at 18:04 UTC
    Hi there all, I am a new comer. where do I start to learn perl? Cheers, --Ed