> I  am new to Win32::GUI.
> I would like to open a simple, plain, main window, with only label 
> objects on it, let say,  and intercept a mouse click anywhere on the 
> client area, so
> that, depending on where the click happens  
> (Win32::GUI::GetCursorPos()),  different actions can be taken.
> It doesn't seem the mouse click event is handled by the main 
> window. True?
> The only solution I can see up to now is to add an 'enormous' button 
> that covers the entire area, let's call it BigBut
> , then add the labels  and define a sub called   BigBut_Click() which 
> calls to Win32::GUI::GetCursorPos() and Win32::GUI::Redraw($main, 1).
> 
> Has any one any idea on how to achieve this scope in a less 
> clumsy way?
> Incidentally: what objects are clickable? More generally, how 
> can I know 
> which events are seen by which objects?
> Thanks in advance for any answer.
> 

You're overthinking it. Here's one simple way: add a label that is the same
size as the window and make it respond to clicks via -notify=>1. Don't
forget to resize it if the window is resized.

-Pete



use Win32::GUI;


my $Window = new Win32::GUI::Window (
        -title    => "Now whole Window is a Label",
        -pos     => [100, 100],
        -size    => [400, 400],
        -name     => "Window",
        );

my $Label = $Window->AddLabel(
        -name => "Label",
        -pos => [0,0],
        -size => [400,400],
        -text => "",
        -notify => 1,
        );

my $Label2 = $Window->AddLabel(
        -name => "Label2",
        -pos => [10,10],
        -text => "This is the second label on top of the first",
        );


$Window->Show();
Win32::GUI::Dialog();



sub Label_Click
{
        print "Got a click\n";
}


sub Window_Terminate
{
        return -1;
}
 

Reply via email to