lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] wxDialog::OnOK() removed from wx


From: Greg Chicares
Subject: Re: [lmi] wxDialog::OnOK() removed from wx
Date: Sun, 24 Sep 2006 23:51:15 +0000
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

On 2006-9-24 23:08 UTC, Vadim Zeitlin wrote:
> On Sun, 24 Sep 2006 22:47:37 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> Vadim--A few weeks ago, you mentioned that wxDialog::OnOK() has
> GC> been removed from the latest version of wx, and said there were
> GC> two ways to deal with situations where 'lmi' calls that function:
> GC> 
> GC> (1) Rewrite the code that calls it.
> GC> 
> GC> The 'lmi' trunk's wxID_OK handler is indeed not necessary, but
> GC> the 'skeleton' trunk does need it--so this is not the universal
> GC> solution, and we need to consider the alternative....
> 
>  I'm looking at skeleton code right now and I found 2 places where OnOK()
> is used:
> 
> 1. in about_dialog.cpp, but there it seems to have nothing to do with
>    wxID_OK button handler

Here, the "Read the GNU General Public License" button is mapped
to wxID_OK, and the other button to wxID_CANCEL. Is there a
less confusing way to accomplish the same thing?

> 2. in mvc_controller.cpp and there I think the same solution applies:
>    it's better to move the code from UponOk() to TransferDataFromWindow()
>    instead of conflating closing the dialog and validating data in it in
>    the same handler. I can make a patch doing this if you'd like.

Here, UponOk()'s purpose is to close the dialog and display some
information. But I really do think Validate() should be called
here, to prevent closing the dialog when validation fails, just
as UponPageChanging() vetoes a book-control page change in the
same circumstance. We really do want to 'lock' users in a control
whose contents are invalid, and force them either to correct the
input or to escape with 'Cancel'.

Perhaps some confusion arises from the word 'validate'. In wx,
a 'validator'
 (A) transfers data
 (B) optionally validates it
 (C) optionally filters keystrokes
but wxValidator::Validate() often does nothing.

In 'lmi', the optional facilities (B) and (C) are never used.
Class Transferor, derived from class wxValidator, does only (A):
  bool Transferor::Validate(wxWindow*) {return true;}

OTOH, 'lmi' does perform validation, but it does that not in a
wxValidator override, but rather in a wxDialog override. We have
  class MvcController : public wxDialog
whose
  virtual bool Validate();
overrides wxDialog::Validate(), completely replacing it (I'll
add a comment to that effect, because it doesn't call Skip());
that function actually performs validation, and doesn't directly
transfer data itself.

So I think it might be better just to do this:

> GC> (2) Write its body inline.

and the former differences in implementation across platforms
don't matter because:

> In the latest wx sources this method is not present at all, of
> course, which takes care of these discrepancies nicely :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]