From c4e41abb01399ea5a38997619286a50f83927c71 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 30 Jan 2011 21:31:45 +0100 Subject: using more modern form run call --- src/newt/test1.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/newt/test1.cpp b/src/newt/test1.cpp index 61185d6..fc8c939 100644 --- a/src/newt/test1.cpp +++ b/src/newt/test1.cpp @@ -1,6 +1,8 @@ #include +extern "C" { #include +} using namespace std; @@ -21,7 +23,7 @@ int main( void ) newtOpenWindow( 10, 3, 60, 18, "form1" ); // construct the components of the form and the form itself - newtComponent form, answer, label1, inputline1, + newtComponent form, label1, inputline1, label2, inputline2, ok, cancel; form = newtForm( NULL, NULL, 0 ); @@ -40,16 +42,29 @@ int main( void ) newtFormAddComponents( form, label1, inputline1, label2, inputline2, ok, cancel, NULL ); // run the form - answer = newtRunForm( form ); + struct newtExitStruct result; + newtFormRun( form, &result ); // cleanup newtPopWindow( ); newtFinished( ); - if( answer == ok ) { - cout << "OK" << endl; - } else if( answer == cancel ) { - cout << "Cancel" << endl; + switch( result.reason ) { + case newtExitStruct::NEWT_EXIT_HOTKEY: + cout << "EXITKEY(" << result.u.key << ")" << endl; + break; + + case newtExitStruct::NEWT_EXIT_COMPONENT: + cout << "COMPONENT EXIT(" << result.u.co << ")" << endl; + break; + + case newtExitStruct::NEWT_EXIT_FDREADY: + cout << "FDREADY(" << result.u.watch << ")" << endl; + break; + + case newtExitStruct::NEWT_EXIT_TIMER: + cout << "TIMER" << endl; + break; } return 0; -- cgit v1.2.3-54-g00ecf