Emulating cancel button
Emulating cancel button
I have a frame which takes multiple text inputs and has OK and CANCEL button. If the user changes any of the text and clicks OK it will be updated in a structure and the frame is hidden. On clicking CANCEL button the changes are not updated. But the problem is whatever changes user has made to the text boxes will be retained. Ideally on clicking CANCEL all the updated changes should revert back to the previous values. How could I solve this?
Maybe:
http://www.wxwidgets.org/manuals/2.6.2/ ... fromwindow
If I get you correctly, you want the values to be written to the internal data structure only when OK is pressed? I assume the dialog closes on OK and on CANCEL? What I always do;
The two functions are own made, I always keep data in classes, so that I can send around pointers that will relect the data in the dialog. This way when the user enters cancel, the class is not updated.
In the dialog, simply move the class contents to the proper GUI elements and back;
And back;
If this is not what you meant, please be more specific about the flow of the dlg and your problem.
Regards,
- Jorgen
http://www.wxwidgets.org/manuals/2.6.2/ ... fromwindow
If I get you correctly, you want the values to be written to the internal data structure only when OK is pressed? I assume the dialog closes on OK and on CANCEL? What I always do;
Code: Select all
MyDialog *dlg = new MyDialog(...);
dlg->TransferDataToDlg(PtrToClass);
if(dlg->ShowModal() == wxID_OK)
dlg->TransferDlgToData(PtrToClass);
dlg->Destroy();
In the dialog, simply move the class contents to the proper GUI elements and back;
Code: Select all
TransferDataToDlg(const MyClass *ptr)
{
m_someTextCtrl->SetValue(ptr->GetTextValue());
m_someCheckBox->SetValue(ptr->IsOptionTrue());
}
Code: Select all
TransferDlgToData(MyClass *ptr)
{
ptr->SetTextValue(m_someTextCtrl->GetValue());
SetOptionTrue(m_someCheckBox->GetValue());
}
Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Is there any way of getting the previous set value in the text ctrl rather than reading from the internal structure.
Consider
A text ctrl with value user123
If this is changed to user456 and then clicked CANCEL, it should revert back to user123 rather than displaying user456.
I mean instead of TransferDataToDlg() can I get the previous set value somehow?
Consider
A text ctrl with value user123
If this is changed to user456 and then clicked CANCEL, it should revert back to user123 rather than displaying user456.
I mean instead of TransferDataToDlg() can I get the previous set value somehow?