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

2011-01-20 Thread Rocco Caputo
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 - rcap...@pobox.com


On Jan 18, 2011, at 13:05, p...@perlmeister.com 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
 p...@perlmeister.com



Passing Sessions with Curses::UI::POE

2011-01-18 Thread poe

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
p...@perlmeister.com