Page 1 of 1

DCGET GETFOCUS with POPUP

Posted: Thu Oct 27, 2016 9:44 pm
by Andy Edward
Hi Roger,

With this code, d and oldbank (inside compare function) is always the same even though oldbank was populated during GETFOCUS

So if I change the DCGET's value to something else, I should expect oldbank will retain the old value in order to compare between the old and new value.

What am I missing here?

Note: Xbase++ 2.0.721 and Express 2.0.263

Code: Select all


USE YTDAP NEW ALIAS GST 

@  0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX SIZE 200,200 ;
   OBJECT oBrowBox

@  1,1  DCBROWSE oBrowse ALIAS 'GST' SIZE 70,70 PARENT oBrowBox;
    PRESENTATION DC_BrowPres() ;
    EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITACROSSDOWN

SELECT GST
OLDBANK := SPACE(100)
DCSETPARENT oBrowse
 DCBROWSECOL FIELD GST->GLAMT    HEADER 'Bank'          WIDTH 8  PICTURE '@!' EDITOR 'BANK1';
          TOOLTIP 'Editable ONLY if the currency is based currency';
          HCOLOR GRA_CLR_BLUE,GRA_CLR_YELLOW    && 20080410

 @nil,nil DCGET bBLOCK1 GETID 'BANK1' PICTURE '@!';
     GOTFOCUS {|| OLDBANK:=GST->GLAMT};   && <----------------------------- 
     POPUP {|| DC_POPCALC()} GETSIZE 8;  && 20161026
     VALID {|o,x,d| d:=O:get:varget(), COMPARE(d, oldbank),DC_GETREFRESH(GETLIST),x} && <----------------------------- 

DCREAD GUI
RETURN

function COMPARE(d,olbank)
wtf d, oldbank
RETURN NIL
Regards,

Andy

Re: DCGET GETFOCUS with POPUP

Posted: Fri Oct 28, 2016 5:58 am
by rdonnay
Put some debugging in your GOTFOCUS code block to see if it is getting evaluated.

Code: Select all

@nil,nil DCGET bBLOCK1 GETID 'BANK1' PICTURE '@!';
     GOTFOCUS {|| OLDBANK:=GST->GLAMT, (WTF OLDBANK)};   <<<<<<<<<<<<<<<<<<
     POPUP {|| DC_POPCALC()} GETSIZE 8;  && 20161026
     VALID {|o,x,d| d:=O:get:varget(), COMPARE(d, oldbank),DC_GETREFRESH(GETLIST),x} 

Re: DCGET GETFOCUS with POPUP

Posted: Fri Oct 28, 2016 6:35 am
by skiman
Maybe the following?

gotfocus {| a,b,o| OldBank :=O:get:varget() }

Re: DCGET GETFOCUS with POPUP

Posted: Fri Oct 28, 2016 7:14 am
by Cliff Wiernik
You need to put in some debugging. But just to let you know what we experienced in the past. It might also apply to the popup. We has a process whereby SSN (social security numbers), when displayed on the screen were masked as xxx-xxx-9999, but when the field was in focus, we changed value to be the actual SSN. We also have the ability via DCHOTKEY xbeK_F12 to allow the user to press the F12 key to print the current screen dialog. Pressing the F12 did not trigger the valid clause, that handled the returning of the actual SSN back to the masked version, but trigger a state so the GOTFOCUS clause was trigger without the corresponding lostfocus processing via the VALID to be processed.

We handled this by disabling the F12 key when in this field. Therefore the GOTFOCUS mask->actual, VALID actual->mask and so forth was always processed. Otherwise, we had instances where the masked value was saved into the file.

You may be experiencing something similar.

Re: DCGET GETFOCUS with POPUP

Posted: Sun Oct 30, 2016 7:41 pm
by Andy Edward
rdonnay wrote:Put some debugging in your GOTFOCUS code block to see if it is getting evaluated.

Code: Select all

@nil,nil DCGET bBLOCK1 GETID 'BANK1' PICTURE '@!';
     GOTFOCUS {|| OLDBANK:=GST->GLAMT, (WTF OLDBANK)};   <<<<<<<<<<<<<<<<<<
     POPUP {|| DC_POPCALC()} GETSIZE 8;  && 20161026
     VALID {|o,x,d| d:=O:get:varget(), COMPARE(d, oldbank),DC_GETREFRESH(GETLIST),x} 
It is being evaluated. I can see the old value.

I notice there are two scenarios,
First scenario - if I edit the cell by entering value via keyboard (ignoring the popup), the compare function will show two different values (old and new). This is correct.
Second scenario - If I edit the cell by using the popup which is a calculator, then I press ok on the calculator, the VALID will trigger and OLDBANK's value is replaced by the new value, which is not correct

Anything else that I'm missing?
skiman wrote:Maybe the following?

gotfocus {| a,b,o| OldBank :=O:get:varget() }
I tried this, and the behavior remains incorrect

Re: DCGET GETFOCUS with POPUP

Posted: Sun Oct 30, 2016 8:00 pm
by rdonnay
Change this:

POPUP {|| DC_POPCALC()} GETSIZE 8;

to this:

POPUP {|n| DC_POPCALC(n)} GETSIZE 8;

Re: DCGET GETFOCUS with POPUP

Posted: Sun Oct 30, 2016 8:55 pm
by Andy Edward
Hi Roger,
rdonnay wrote:Change this:

POPUP {|| DC_POPCALC()} GETSIZE 8;

to this:

POPUP {|n| DC_POPCALC(n)} GETSIZE 8;
The same issue still persists. Any other ideas?

Regards,

Andy

Re: DCGET GETFOCUS with POPUP

Posted: Thu Nov 17, 2016 2:41 am
by Andy Edward
Hi Roger,

Here is the .exe where you can see the behaviour.

Thanks in advance.
getfocust.zip
(26.24 KiB) Downloaded 732 times
Regards,

Andy