Re: Passing Sessions with Curses::UI::POE

[email protected] (Rocco Caputo) Fri, 21 Jan 2011 01:21:11 -0500
Newsgroups perl.poe
Message-ID <[email protected]>
Check out POE::Session's postback() and callback() methods, which were created for this sort of thing.  These generate anonymous coderefs that post() or call() the invocant session.  For example:

$CUI->set_binding( $SESSION->postback("blah"), "b" );

See the docs for side effects, including numbness, shortness of breath, upset stomach, and the ability to smell concepts that can't be expressed in a single English word.

-- 
Rocco Caputo - [email protected]


On Jan 18, 2011, at 13:05, [email protected] wrote:

> Using Curses::UI::POE and the key binding function set_binding(), I've been
> using a global session variable to trigger events in POE:
> 
>     use POE;
>     use Curses::UI::POE;
> 
>     my $SESSION;
> 
>     my $CUI = Curses::UI::POE->new(
>       inline_states  => {
>         _start => sub { $SESSION = $_[SESSION]; },
>         blah   => sub { # ...
>         },
>     });
> 
>     $CUI->set_binding( sub { exit 0; },   "q");
>     $CUI->set_binding( sub {
>         $poe_kernel->post( $SESSION, "blah" );
>     }, "b");
> 
>     $CUI->mainloop;
> 
> Is there a better way to post events to the Curses::UI::POE session 
> created earlier when the user presses a particular key?
> 
> -- Mike
> 
> Mike Schilli
> [email protected]