FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Get with on Change
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Get with on Change
Posted: Fri Jan 06, 2012 04:01 PM
Hi,

I have a curious problem with some get fields with the ON CHANGE clause

I have 5 get fields, three of them have the ON CHANGE clause to validate all of the three gets and to activate a save-button, if all are valid.
the curiosity is now, that only two fields seem to follow the roules of the ON CHANGE clause.

Code (fw): Select all Collapse
REDEFINE GET oUser VAR cUser ID 104 OF oDlg VALID !Empty (cUser) ;
         ON CHANGE IIF ( (oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() )
REDEFINE GET cStreet  ID 105 OF oDlg
REDEFINE GET oCity VAR cCity ID 106 OF oDlg VALID !Empty (cCity) ;
         ON CHANGE IIF ((oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() )
REDEFINE GET oCountry VAR cCountry ID 107 OF oDlg VALID !Empty (cCountry)
REDEFINE GET oEmail VAR cEmail ID 108 OF oDlg VALID !Empty (cEmail) ;
         ON CHANGE IIF ((oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() )


I enter some text in the first get (oUser), jump with TAB to cStreet and oCity, enter some text in both gets. The button is still inactive. Now I jump with TAB to the next get (oCountry) and the button is activated although oEmail:lValid() returns still .f. ??

How can the button get activated although the condition is wrong ? What do I miss ?
kind regards

Stefan
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Get with on Change
Posted: Sat Jan 07, 2012 05:31 AM
I am not able to reproduce the behavior as said by you.

Code (fw): Select all Collapse
#include "Fivewin.ch"
//--------------------//
Function Main()
    
    Local oUser,oCity,oCountry,oEmail,oSave,oCancel,oDlg
    Local cUser,cCity,cCountry,cEmail,cStreet
    cUser:=cCity:=cCountry:=cEmail:=cStreet:=Space(100)
    
    DEFINE DIALOG oDlg FROM 10,10 to 26,115
    
    @0.8,1 SAY "User"
    @1.7,1 SAY "Street"
    @2.6,1 SAY "City"
    @3.5,1 SAY "Country"
    @4.4,1 SAY "Email"    
    
    @1,5 GET oUser VAR cUser OF oDlg VALID !Empty (cUser) ;
             ON CHANGE IIF ( (oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() )
    @2,5 GET cStreet  OF oDlg
    @3,5 GET oCity VAR cCity OF oDlg VALID !Empty (cCity) ;
             ON CHANGE IIF ((oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() )
    @4,5 GET oCountry VAR cCountry OF oDlg VALID !Empty (cCountry)
    @5,5 GET oEmail VAR cEmail OF oDlg VALID !Empty (cEmail) ;
             ON CHANGE IIF ((oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() )
             
    @5,25 BUTTON oSave PROMPT "SAVE"         
    @5,35 BUTTON oCancel PROMPT "Cancel" CANCEL ACTION oDlg:End()
    
    ACTIVATE DIALOG oDlg ON INIT oSave:Disable()
    
RETURN NIL

Anser
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Get with on Change
Posted: Sat Jan 07, 2012 12:43 PM

Hmm, I´m using a dialog from resource, maybe that´s the difference.

I will test your sample and report you

kind regards

Stefan
Posts: 55
Joined: Fri Jul 08, 2011 06:43 AM
Re: Get with on Change
Posted: Sat Jan 07, 2012 03:03 PM
Stefan

Why not using the valid clausule as :
Code (fw): Select all Collapse
VALID !Empty (cUser)  .AND. ( IIF ( (oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() ) , .T. )


Frank
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Get with on Change
Posted: Sat Jan 07, 2012 04:28 PM

Ok, I´ve got it. Sometimes you don´t see the wood for the trees :?

The problem was that the button itself had a WHEN clause and this was causing the curious behavior. Now I disabled the button with ON INIT and deleted the WHEN clause of the button. Everything is working fine now :D

Thanks for the help

kind regards

Stefan

Continue the discussion