Where is wxDialog::OnOK in wxWidgets 2.7?
In help file for wxWidgets 2.7 it's defined. I found needed function in wx/univ/dialog.h but not in wx/dialog.h.
If I include file from univ directory I got a lot of "second time defined" classess...
Any help would be appreciated
Tomek
wxDialog::OnOK in wxWidgets 2.7
Simply add at the top of your source file (.h or .cpp).
Code: Select all
#include <wx/dialog.h>
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Actually, all the OnOK/OnCancel type functions are in the middle of being removed in favor of the single EndDialog(int id) (not EndModal) function. It makes a little more sense since for stuff like wxStdDialogButtonSizer, some of those buttons are labeled differently on other platforms.
It looks like this was something that wasn't finished when the 2.7.1 release was made because EndDialog still isn't documented yet, that or it was forgotten about. It's also possible that I'm wrong as I haven't read anything on wx-dev about this taking place, but I've found that EndDialog works just as well as a replacement.
It looks like this was something that wasn't finished when the 2.7.1 release was made because EndDialog still isn't documented yet, that or it was forgotten about. It's also possible that I'm wrong as I haven't read anything on wx-dev about this taking place, but I've found that EndDialog works just as well as a replacement.
Would it make sense to have a deprecated function wxDialog::OnOK in 2.7.1 that was just
Otherwise you need #ifdefs to separate code for 2.6.x and 2.7.x (since the EndDialog function isn't present in the 2.6.x branch). I could be mistaken, but I thought that the usual practice was to have the old function present at the same time as the new function for at least a couple releases to allow for user migration.
Code: Select all
wxDialog::OnOK()
{
EndDialog(wxID_OK);
}
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
On further inspection, it looks like OnOK (along with others) used to be defined separately by each port. Vadim aparently noticed this, and made a commit taking out the functions about 2 months ago with a note explaining that they were to be moved to the base class, but I don't see the addition of the functions to the base class. I'll bring this up on the wx-dev list.jb_coder wrote:Would it make sense to have a deprecated function wxDialog::OnOK in 2.7.1
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
You can find the reply here:
http://thread.gmane.org/gmane.comp.lib. ... ocus=79043
So it aparently looks like these are just going to be removed for good, no deprecation.
http://thread.gmane.org/gmane.comp.lib. ... ocus=79043
So it aparently looks like these are just going to be removed for good, no deprecation.
jb_coder wrote:Would it make sense to have a deprecated function wxDialog::OnOK in 2.7.1 that was just
Otherwise you need #ifdefs to separate code for 2.6.x and 2.7.x (since the EndDialog function isn't present in the 2.6.x branch). I could be mistaken, but I thought that the usual practice was to have the old function present at the same time as the new function for at least a couple releases to allow for user migration.Code: Select all
wxDialog::OnOK() { EndDialog(wxID_OK); }
Code: Select all
void SubClassOf_wxDialog::OnOK(wxCommandEvent& /*event*/)
{
this->wxDialog::SetAffirmativeId(wxID_OK);
this->wxDialog::AcceptAndClose();
}
Tim S
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
What Vadim was saying in the thread on the mailing list is that if you are using the default wxID_OK for your OK button (and your code indicates you are), and you don't need to do anything special before closing the dialog, then you don't need to write an OnOK event handler. Also, if you do use a different ID other than wxID_OK, you can still just use the new SetAffirmativeId() function when you setup your dialog, and still not have to write an OnOK handler. So basically, the replacement would be to take out the handler altogether. If you do still need one, just call event.Skip(), and nothing else is needed.stahta01 wrote:Is my above code OK for 2.7.1 as a replacement of OnOK in a class that is a subclass of wxDialog?Code: Select all
void SubClassOf_wxDialog::OnOK(wxCommandEvent& /*event*/) { this->wxDialog::SetAffirmativeId(wxID_OK); this->wxDialog::AcceptAndClose(); }