in reply to trying to populate curses menus from text files
... should be read from text file ...
What text file where? :) How do I post a question effectively?
my @menu = ( { -label => 'File', -submenu => [ { -label => 'Exit ^Q', -value => '\&exit_dialog' }, { -label => 'Wait ^W', -value => '\&remain_dialog' } +, ], }, ); use JSON; print encode_json({menu=>\@menu}); __END__ { "menu" : [ { "-label" : "File", "-submenu" : [ { "-label" : "Exit ^Q", "-value" : "\\&exit_dialog" }, { "-label" : "Wait ^W", "-value" : "\\&remain_dialog" } ] } ] }
Then
my $menu = decode_json( path( $jsonfile )->slurp_raw ); my $funcname = $menu->{menu}[0]{"-submenu"}[0]{"-value"}; my $funcref = $callback{$funcname}; $menu->{menu}[0]{"-submenu"}[0]{"-value"} = $funcref;
I need to read each -label from a line of the text file and pass the name of the menu (== the filename) and the label to the subroutine called when the item is selected.
Your callback will get the menuitem object as argument, you can (usually) query/interrogate/examine this to retrieve the label
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: trying to populate curses menus from text files (text format)
by boscaiolo (Initiate) on Nov 02, 2013 at 12:06 UTC |