From f1f2d9626af2f6104d8b90bcb16aac5e2f7295a9 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sun, 30 Aug 2015 15:30:15 +0200 Subject: Added event_timeout rw attribute to GUI::Dialog to allow manage $yui::YEvent::TimeoutEvent --- lib/ManaTools/Shared/GUI/Dialog.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/ManaTools/Shared/GUI/Dialog.pm b/lib/ManaTools/Shared/GUI/Dialog.pm index 45fc151f..428130af 100644 --- a/lib/ManaTools/Shared/GUI/Dialog.pm +++ b/lib/ManaTools/Shared/GUI/Dialog.pm @@ -23,6 +23,8 @@ my $dlg = ManaTools::Shared::GUI::Dialog->new( $ManaTools::Shared::GUI::Dialog::cancelButton, $ManaTools::Shared::GUI::Dialog::okButton, ], + event_timeout => 0, # optional nd rw timeout in msec during the waitForEvent() + # needs a ManaTools::Shared::GUI::Event to manage the $yui::YEvent::TimeoutEvent layout => sub { my $self = shift; my $layoutstart = shift; my $dlg = $self->dialog(); my $info = $self->info(); ... $self->addWidget('button1', $button, sub{...}, $backendItem1); }, restoreValues => sub { my $self = shift; $info = {}; ...; return $info }, result => sub { my $self = shift; ... }, @@ -140,6 +142,17 @@ has 'dialog' => ( }, ); +subtype 'TimeoutType' + => as Int + => where {($_ >= 0)}; + +has 'event_timeout' => ( + is => 'rw', + isa => 'TimeoutType', + lazy => 1, + default => 0, +); + our $mainDialog = 1; our $popupDialog = 2; @@ -406,7 +419,7 @@ sub call { # main loop while(1) { - my $yevent = $ydialog->waitForEvent(1000); + my $yevent = $ydialog->waitForEvent($self->event_timeout); last if (!$self->processEvents($yevent)); } -- cgit v1.2.1