(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/* test CLine without using CDialog - Peter Liu */
void testLineEditOnly() {
int loop = 0;
bool i = true;
bool insert = true;
bool done = false;
char str[81] = "I want to edit this thing!";
CLabel label("Enter some text down here:", 6, 4);
CLabel label3("Testing Label and Line edit ONLY", 0, 12);
CLabel label32("- use UP/DOWN/ENTER/ESC to quit editing; use F2 to exit the program", 1, 12);
CLabel label_Name("Name: ", 4, 3); // row:4, column:3
CLine line_Name(4, 9, 20, 40, &insert); // row:4, column:9
// draw label
CLine line_str(str, 7, 4, 40, 80, &insert, true);
label3.draw(); // row: 0
label32.draw(); // row: 1
label_Name.draw(); // row: 4
line_Name.draw(); // row: 4
label.draw(); // row: 6
line_str.draw(); // row: 7
//press F2 to exit
int key;
do {
key = line_str.edit(); // ESC, UP, DOWN: exit the editing mode
switch(key) {
case F(2): // exit the loop (i.e. the funciton)
done = true;
break;
default:
key = line_Name.edit(); // ESC, UP, DOWN: exit the editing mode
}
} while(!done);
//final output on the console
console.clear();
console.setPosition(10, 0);
console << "BYE BYE!";
console.setPosition(14, 0);
}