TestButtonOnly

From CDOT Wiki
Jump to: navigation, search
// Peter Liu's version
void testButtonOnly() {
    int fn       = C_NO_FRAME;  // or C_FULL_FRAME
    CButton inc("Increase", 9, 10);
    CButton dec("Decrease", 9, 30);
    CButton three("Hello", 12, 25); // row number: 12, column number: 25
                                   
    inc.draw(fn);
    dec.draw(fn);
    three.draw(fn);
   
    char s[100];
    int k=1;
   
    // instructions
    console.setPosition(1,1);
    console << "1. Press ENTER/SPACE.  2. Press any other keys!";
   
    // display 3 buttons
   
    k = dec.edit();  //set the focus on the button
    k += 1000;
    std::sprintf(s, "%d", k);
   
    console.setPosition(5, 5);
    console << "1. key value = " << s;
   
    k = inc.edit(); // set the focus on the button
    k += 2000;
    std::sprintf(s, "%d", k);
   
    console.setPosition(7, 15);
    console << "2. key value = " << s;
   
    k = three.edit();  // set the focus on the button
    k += 3000;
    std::sprintf(s, "%d", k);
   
    console.setPosition(15, 15);
    console << "3. key value = " << s;
   
    // wait for user input to exit the function
    int anykey;
    console >> anykey;
    console.clear();
}