I am new to all this DXL malarky and am finding dialog boxes to be most frustrating! I am trying to create a dialog box with a simple text entry that could be called each time the code loops. I want:
How on earth do I achieve that? Any and all help gratefully received. Thanks. Dangthrimble - Sat Mar 12 08:22:07 EST 2011 |
Re: Dialog box to update DXL variable
You use global variables for the dialog return value and parameters for the changed dialog elements. For the OK and cancel/close you use different button callbacks, which will set the global variable. Example:
bool gbInputBoxOK_ = true
string makeInputBox(string sTitle, string sLabel, string fldLabel, bool &bResult) {
void cb_cancel(DB x) { gbInputBoxOK_ = false; hide x }
void cb_ok (DB x) { gbInputBoxOK_ = true ; hide x }
DB diag = centered sTitle
left diag
// use the function parameters to create the contents of
// the dialog box
label (diag, sLabel)
DBE fld = field (diag, fldLabel, "", 40, false)
close (diag, false, cb_cancel)
ok (diag, "Cancel", cb_cancel) // on cancel we will set gbInputBoxOK=false
ok (diag, "OK", cb_ok) // on OK we will set gbInputBoxOK = true
block diag; release diag
// so the developer calling this function won't need to know about the
// gbInputBoxOK_ variable, we pass the result by reference back to the caller
bResult = gbInputBoxOK_
string sResult = get fld
destroy diag
if (gbInputBoxOK_) return sResult else return ""
}
int i; for i in 0:3 do {
bool bOK = false
string val = makeInputBox("parameter " i "", "Please enter:", "I" i "", bOK)
if (bOK) print "The user entered: " val "\n" else print "Cancelled by user!\n"
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Dialog box to update DXL variable Mathias Mamsch - Sat Mar 12 16:32:48 EST 2011
You use global variables for the dialog return value and parameters for the changed dialog elements. For the OK and cancel/close you use different button callbacks, which will set the global variable. Example:
bool gbInputBoxOK_ = true
string makeInputBox(string sTitle, string sLabel, string fldLabel, bool &bResult) {
void cb_cancel(DB x) { gbInputBoxOK_ = false; hide x }
void cb_ok (DB x) { gbInputBoxOK_ = true ; hide x }
DB diag = centered sTitle
left diag
// use the function parameters to create the contents of
// the dialog box
label (diag, sLabel)
DBE fld = field (diag, fldLabel, "", 40, false)
close (diag, false, cb_cancel)
ok (diag, "Cancel", cb_cancel) // on cancel we will set gbInputBoxOK=false
ok (diag, "OK", cb_ok) // on OK we will set gbInputBoxOK = true
block diag; release diag
// so the developer calling this function won't need to know about the
// gbInputBoxOK_ variable, we pass the result by reference back to the caller
bResult = gbInputBoxOK_
string sResult = get fld
destroy diag
if (gbInputBoxOK_) return sResult else return ""
}
int i; for i in 0:3 do {
bool bOK = false
string val = makeInputBox("parameter " i "", "Please enter:", "I" i "", bOK)
if (bOK) print "The user entered: " val "\n" else print "Cancelled by user!\n"
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Jonathan |
Re: Dialog box to update DXL variable |