Get with on Change

Get with on Change

Postby StefanHaupt » Fri Jan 06, 2012 4: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: Select all  Expand view
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Get with on Change

Postby anserkk » Sat Jan 07, 2012 5:31 am

I am not able to reproduce the behavior as said by you.

Code: Select all  Expand view
#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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Get with on Change

Postby StefanHaupt » 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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Get with on Change

Postby Demont Brecht » Sat Jan 07, 2012 3:03 pm

Stefan

Why not using the valid clausule as :
Code: Select all  Expand view

VALID !Empty (cUser)  .AND. ( IIF ( (oUser:lValid() .and. oCity:lValid().and. oEmail:lValid()), oSave:Enable (), oSave:Disable() ) , .T. )
 


Frank
Demont Brecht
 
Posts: 55
Joined: Fri Jul 08, 2011 6:43 am

Re: Get with on Change

Postby StefanHaupt » Sat Jan 07, 2012 4: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 118 guests