Page 1 of 2

xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Wed Jun 21, 2017 8:00 pm
by Rick Lipkin
Rao

Recently something has changed with xBrowse with the EDIT_GET block .. using :lTabLikeExcel := .t. .. when I put a price 69.95 in this block :
Code: Select all  Expand view

//  Price
      oLbxB:aCols[8]:nEditType := EDIT_GET
       oLbxB:aCols[8]:bOnPostEdit := {|o,p| _GetPrice( p,oLbxB,oRsDetail,oRsRepair,lTaxable,oTaxable,;
                                                      oLabor,oParts,oMisc,oTax,oTotal,cTaxSet) }
 


and Hit the TAB key .. the block resolved 69.00 .. If I hit the ENTER key, the block resolves 69.95 ... I am using FWH 1705 ... this behavior recently showed up either in 1705 or 1704.

Appreciate your help!

Rick Lipkin

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Thu Jun 22, 2017 5:23 pm
by nageswaragunupudi
There is no change in xbrowse code.
I am unable to comment because I do not know what is inside the postedit code.

It is desirable and safer if we leave XBrowse to work with its own default codeblock for bOnPostEdit.
If you write your own codeblock you should be able to resolve these complexities

If we press Enter key, any pending edit is confirmed
If we press TAB, if there is any pending edit, CancelEdit() is called and the cursor moves to the next cell

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Fri Jun 23, 2017 1:39 pm
by Rick Lipkin
Rao

My code has not changed in years .. here is what is happening .. I tab thru the cells to the Price column .. I enter 69.95 as you see here

Image

Then when I hit the TAB key ... and I pass P to the EDIT_GET code block and I trap the value with msginfo

Image

The value for the decimals is truncated to .00 ...

Image


If I repeat the same process and use the Enter key I get the expected 69.95 with the full decimal ... here is the code block that has not changed ...
Code: Select all  Expand view

 //  Price
          oLbxB:aCols[8]:nEditType := EDIT_GET
          oLbxB:aCols[8]:bOnPostEdit := {|o,p| _GetPrice( p,oLbxB,oRsDetail,oRsRepair,lTaxable,oTaxable,;
                                                      oLabor,oParts,oMisc,oTax,oTotal,cTaxSet) }
          // extention
          ADD oCol TO oLbxB AT 9 DATA {|x| x :=  _CalcExt( oRsDetail:Fields("Qty"):Value,;
                                    oRsDetail:Fields("Price"):Value )} HEADER 'Ext' size 65
          oLbxB:aCols[9]:nEditType := EDIT_NONE
          oLbxB:aCols[9]:nDataStrAlign := AL_RIGHT
          oLbxB:aCols[8]:nHeadStrAlign := AL_RIGHT


//--------------------------------
Static Func  _GetPrice( nP,oLbxMain,oRsDetail,oRsRepair,lTaxable,oTaxable,;
                        oLabor,oParts,oMisc,oTax,oTotal,cTaxSet)

Local nOldPrice,nQ,Saying

msginfo(nP) // nP should be 69.95 .. not 69.00


If oRsDetail:Fields("IsLabor"):Value = .t.
   Saying := "Sorry .. you can not EDIT this Price because there is Itemization"+chr(10)
   Saying += "under the Labor Column. In order to Change this Price you must go"+chr(10)
   Saying += "back to the Labor column and Edit or Delete your Changes there"+chr(10)
   MsgInfo( Saying )
   oLbxMain:GoLeftMost()
   oLbxMain:nColSel(2)
   Return(.f.)
Endif

nOldPrice := oRsDetail:Fields("Price"):Value
nQ        := oRsDetail:Fields("Qty"):Value

If nP = nOldPrice
   oLbxMain:ReFresh()
   oLbxMain:nColSel(2)
   oLbxMain:SetFocus()
   Return(.t.)
Endif

oRsDetail:Fields("Price"):Value := nP
oRsDetail:Update()

_ReCalcTotals( oRsDetail,oRsRepair,@lTaxable,oTaxable, ,oLbxMain,;
                        oLabor,oParts,oMisc,oTax,oTotal,cTaxSet  )

oLbxMain:ReFresh()
oLbxMain:nColSel(2)
oLbxMain:SetFocus()

Return(.T.)

//--------------------------------------
Static Func _CalcExt( nQuantity,nPrice )

//recalcs ext to paint listbox

Local nExtension

nExtension := Round((nQuantity * nPrice),2)

Return( nExtension )

 

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Fri Jun 23, 2017 3:13 pm
by nageswaragunupudi
What was the existing value before entering 69.95?

The behavior of xbrowse is this:
If you press Enter, you will see 69.95
If you press Tab, you will see the value existing already

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Fri Jun 23, 2017 3:42 pm
by Rick Lipkin
Rao

This was a new row created by the function _AddNewRow() .. the value of Price was 0 before anyone traverses into the cell.

Rick Lipkin



Code: Select all  Expand view

//----------------
Static Func _AddNewRow( oRsDetail,nRN,nTech,cLocation,oBrw,cAsk,oRsRepair,cReturn )

Local Saying,nEid,nLine,nUpdated

If empty( cAsk )
   cAsk := "Y"
Endif

If Empty(cReturn)
   cReturn := "ADD"
ENdif


If cAsk = "Y"

   Saying := "Do you wish to Add a New Record ?"
   If MsgYesNo( Saying )
   Else
      oBrw:SetFocus()
      Return(.f.)
   Endif

Endif

nEid := _GenEid(1)
If nEid = -1
   Saying := "Error in Creating Unique EID for Repair Detail"
   Msginfo( Saying )
   oBrw:SetFocus()
   Return(.f.)
Endif

nLine := _GenLine()
If nLine = -1
   Saying := "Error in Creating Unique LINE for Repair Detail"
   Msginfo( Saying )
   oBrw:SetFocus()
   Return(.f.)
Endif

// update the concurrent counter in repair header

nUpdated := oRsRepair:Fields("Updated"):Value

If Empty(nUpdated)
   nUpdated := 1
Else
   nUpdated++
Endif

oRsRepair:Fields("Updated"):Value := nUpdated
oRsRepair:Update()

oRsDetail:AddNew()

oRsDetail:Fields("RepDetailEid"):Value     := nEid
oRsDetail:Fields("Unique Line"):Value      := nLine
oRsDetail:Fields("Repair Number"):Value    := nRn

If cReturn = "RETURN"
   oRsDetail:Fields("Qty"):Value              := -1
Else
   oRsDetail:Fields("Qty"):Value              := 1
Endif

oRsDetail:Fields("Item Description"):Value := space(100)
oRsDetail:Fields("Price"):Value            := 0                              // <---------------------   here is the value of Price
oRsDetail:Fields("Tech Number"):Value      := nTech
oRsDetail:Fields("Inventory Id"):Value     := space(50)
oRsDetail:Fields("Inventory Type"):Value   := space(50) //"Labor"+space(45)
oRsDetail:Fields("Cost"):Value             := 0
oRsDetail:Fields("Covered By Warranty"):Value := .f.
oRsDetail:Fields("Location"):Value         := cLocation
oRsDetail:Fields("Code"):Value             := space(25)
*oRsDetail:Fields("Shipping Ref"):Value     := space(64)
oRsDetail:Fields("Serial Number"):Value    := space(50)
oRsDetail:Fields("NoTax"):Value            := 0
oRsDetail:Fields("Warranty Provider"):Value := space(50)
*oRsDetail:Fields("Quote Price"):Value      := 0
oRsDetail:Fields("LockedDown"):Value       := .f.
oRsDetail:Fields("IsSerial"):Value         := .f.
oRsDetail:Fields("IsLabor"):Value          := .f.
oRsDetail:Update()

oBrw:ReFresh()
oBrw:nColSel(3) // move to part number on add
oBrw:SetFocus()

Return(.t.)

 

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Fri Jun 23, 2017 3:51 pm
by Rick Lipkin
Rao

You were on the right track ... I added 0.00 ( decimal ) to Price in _AddNewRow() .... and now it WORKS !!

Thanks for pointing me in the right direction ..

Rick Lipkin

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao ).. SOLVED

PostPosted: Fri Jun 23, 2017 3:57 pm
by nageswaragunupudi
The best way is to test with as small program as possible
I am testing with this program
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   XBROWSER "CUSTOMER.DBF" FASTEDIT ;
      COLUMNS "FIRST", "SALARY", "CITY" ;
      TITLE FWVERSION ;
      SETUP ( oBrw:lTabLikeExcel := .t., ;
      oBrw:Salary:lAutoSave := .f., ;  // toggle and check
      oBrw:Salary:bOnPostEdit := { |o,x,k| MsgInfo( x ) } )

return nil
 

I find difference in the behavior between 17.03 and 17.05.
I try to locate the change and let you know.
I did not save 17.04 version.

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Fri Jun 23, 2017 4:04 pm
by Rick Lipkin
Rao

Unfortunately adding 0.00 to Price in _AddNewRow() made NO difference ... I still get 69.00 when I trap the EDIT_GET code block value nP ... :)

Rick Lipkin

ps I just updated to FWH 1706 a few minutes ago

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Fri Jun 23, 2017 4:52 pm
by Rick Lipkin
Rao

I just compiled your sample and changed the Salary to 69.95 and Tabbed thru the cell and your msginfo resolved 69.00 instead of 69.95... and the previous existing value decimal value was .00

At least we are able to re-create the tabbed behavior.

Rick Lipkin

Image

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Mon Jun 26, 2017 7:37 pm
by Rick Lipkin
Rao

Any News ?

Thanks
Rick Lipkin

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Tue Jun 27, 2017 4:16 am
by nageswaragunupudi
Mr Rick
I need some more time please

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Thu Jul 13, 2017 2:33 pm
by Rick Lipkin
Rao

Hope you enjoyed the conference ... have you had a chance to re-examine this issue ?

Thanks
Rick Lipkin

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Tue Jul 25, 2017 12:25 pm
by Rick Lipkin
Rao

Forgive me .. just wanted to keep this on your radar ... Thanks for your Help !

Rick Lipkin

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Sat Jul 29, 2017 4:32 pm
by nageswaragunupudi
Sorry for the delay.

Please locate static function EditGetkeyDown( Self, nKey ) in xbrowse.prg.
In that function please locate the code
Code: Select all  Expand view
     case nKey == VK_RETURN

Modify this line as
Code: Select all  Expand view
     case nKey == VK_RETURN .or. nKey == VK_TAB


Please let us know the result

Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )

PostPosted: Mon Jul 31, 2017 2:17 pm
by Rick Lipkin
Rao

case nKey == VK_RETURN was found in two places

1) KeyChar()
2) EditGetKeyDown()

I made the change in both places to case nKey == VK_RETURN .or. nKey == VK_TAB

You modification WORKED !!

Thank You VERY Much

Rick Lipkin