Page 1 of 1

GET WITH "ON CHANGE" PROBLEM

Posted: Thu Apr 20, 2006 12:00 am
by Boris
We are using:
xHarbour built 01/24/06
All FWH libraries from 03/15/06

We have GET problem (simplified, it looks like this):
At the entering to dialog:
nSalary := 7,500.00
cText := "SOME TEXT"
....
REDEFINE GET oGet1 VAR nSalary ID 101 OF oDlg ;
ON CHANGE (cText := "CHANGED",oget2:SetText(cText),oget2:refresh()) UPDATE

REDEFINE GET oget2 VAR cText ID 102 OF oDlg UPDATE
....

Now, if we click into the oGet1 GET field and just hit enter to continue,
the cText becomes "CHANGED" and oGet2 is refreshed with this content.
Even if we DID NOT CHANGE the content of oGet1 VAR nSalary !!

Basicaly what happens is that no mater if the "nSalary" variable IS changed or NOT
after we leave it by hitting ENTER or TAB, the "ON CHANGE" clause evaluates
as TRUE and because of this, the rest of code
is evaluated (changes variable cText to "CHANGED")
and oGet2 GET shows "CHANGED" on dialog!

Is there a fix for this, or there is something which was changed either in xHArbour
or FWH?

Thanks for any help or advice

Re: GET WITH "ON CHANGE" PROBLEM

Posted: Thu Apr 20, 2006 6:18 pm
by E. Bartzokas
Boris wrote:...
Basicaly what happens is that no mater if the "nSalary" variable IS changed or NOT
after we leave it by hitting ENTER or TAB, the "ON CHANGE" clause evaluates
as TRUE and because of this, the rest of code
is evaluated (changes variable cText to "CHANGED")
and oGet2 GET shows "CHANGED" on dialog!

Is there a fix for this, or there is something which was changed either in xHArbour
or FWH?

Thanks for any help or advice
Boris,
I do not expect any response, due to the fact that it's too hard to find out why this is happening.
I have solved the problem, and have sent you an updated TGET.PRG though your private email.

If any one cares to know how I solved it, then here's a brief description....
In Method KeyChar of TGET.PRG, I evaluate the code blocks for ON CHANGE, only if the original content of the variable is changed.
I use:
IF (::oGet:changed .or. ::oGet:unTransform() <> ::oGet:original)
lAccept = Eval( ::bChange, nKey, nFlags, Self )
...
ENDIF

This IF-ENDIF has been added in both
case nKey == VK_TAB .and. GetKeyState( VK_SHIFT )
and in
case nKey == VK_TAB .or. nKey == VK_RETURN

Regards to all and Happy Easter to the Orthodox Christians.

Evans Bartzokas

ps. Yes, we create a PDF from inside our modified RPREVIEW.PRG, and Yes, we e-mail this PDF as an attachment.
:D

Posted: Thu Apr 20, 2006 6:57 pm
by Antonio Linares
Boris,

As Evans has pointed, this may be the required fix in Class TGet:

Code: Select all

      case nKey == VK_TAB .or. nKey == VK_RETURN
           if ::bChange != nil .and. ( ::oGet:Changed .or. ::oGet:UnTransform() != ::oGet:Original )
              lAccept = Eval( ::bChange, nKey, nFlags, Self )
              if ValType( lAccept ) == "L" .and. lAccept
                 ::oWnd:GoNextCtrl( ::hWnd )
              endif
           else
              ::oWnd:GoNextCtrl( ::hWnd )
           endif