From bd24d05a9141c5a24fbefef9b82a7f82effb8e35 Mon Sep 17 00:00:00 2001 From: cy384 Date: Mon, 20 Jul 2020 15:30:56 -0400 Subject: [PATCH] add cancel button to intro dialog --- ssheven.c | 9 ++++++--- ssheven.r | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ssheven.c b/ssheven.c index f0ab530..661234d 100644 --- a/ssheven.c +++ b/ssheven.c @@ -356,7 +356,7 @@ void ssh_setup_terminal(void) SSH_CHECK(libssh2_channel_shell(ssh_con.channel)); } -void intro_dialog(char* hostname, char* username, char* password) +int intro_dialog(char* hostname, char* username, char* password) { // modal dialog setup @@ -394,7 +394,7 @@ void intro_dialog(char* hostname, char* username, char* password) short item; do { ModalDialog(NULL, &item); - } while(item != 1); + } while(item != 1 && item != 9); // copy the text out of the boxes GetDialogItemText((Handle)address_text_box, hostname); @@ -404,6 +404,9 @@ void intro_dialog(char* hostname, char* username, char* password) // clean it up CloseDialog(dlg); FlushEvents(everyEvent, -1); + + // if we hit cancel, 0 + if (item == 9) return 0; else return 1; } //enum { WAIT, READ, EXIT } read_thread_command = WAIT; @@ -461,7 +464,7 @@ int main(int argc, char** argv) InitWindows(); InitMenus(); - intro_dialog(hostname, username, password); + if (!intro_dialog(hostname, username, password)) return 0; console_setup(); diff --git a/ssheven.r b/ssheven.r index ca036be..e8f799c 100644 --- a/ssheven.r +++ b/ssheven.r @@ -36,6 +36,9 @@ resource 'DITL' (128) { { 135, 10, 151, 310 }, EditText { enabled, "" }; + + { 190-10-20, 10, 190-10, 90 }, + Button { enabled, "Cancel" }; } };