#47 timer do not works with new event model

closed
Robert May
None
1
2005-08-19
2005-08-04
Anonymous
No

onTimer event hadler in script below is never executed
(no output to console). But it starts executing if used old
event model (mw_terminate sub) instead of onTerminate
parameter in main window constructor

use strict;
use Win32::GUI;

my $mw = Win32::GUI::Window->new(-name => 'mw',
-size => [400, 400],
-pos => [200, 200],
-title => "FormsTest",
-onTerminate => sub{return -1;},
);

my $t1 = Win32::GUI::Timer->new($mw, 'T1', 2000);

$mw->Show;
Win32::GUI::Dialog;

sub T1_Timer {
local $| = 1;
print "Handler starts";
my $flag = $mw->IsVisible();
if ($flag) {
$mw->Hide();
}
else {
$mw->Show();
}
print "Handler ends";
return 1;
}

Discussion

  • Logged In: NO

    I dont think this is a bug - as this code is mixing OEM/NEM
    events for the window. Adding the NEM timer event fixes
    things:

    use strict;
    use Win32::GUI;

    my $mw = Win32::GUI::Window->new(-name => 'mw',
    -size => [400, 400],
    -pos => [200, 200],
    -title => "FormsTest",
    -onTerminate => sub{return -1;},
    -onTimer => \&T1_Timer,
    );

    my $t1 = Win32::GUI::Timer->new($mw, 'T1', 2000);

    $mw->Show;
    Win32::GUI::Dialog;

    sub T1_Timer {
    local $| = 1;
    print "Handler starts";
    my $flag = $mw->IsVisible();
    if ($flag) {
    $mw->Hide();
    }
    else {
    $mw->Show();
    }
    print "Handler ends";
    return 1;
    }

     
  • Robert May
    Robert May
    2005-08-04

    Logged In: YES
    user_id=674651

    This is not a bug. Using an NEM handler on a window
    disables OEM events from being triggered. If you must use
    both (and I don't recommend this, as it gets very confusing),
    then pass the -eventmodel => 'both' option to the constructor.

    Regards,
    Rob.

     
  • Robert May
    Robert May
    2005-08-04

    • priority: 5 --> 1
    • assigned_to: nobody --> robertemay
    • status: open --> pending
     
  • Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
    • status: pending --> closed