FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Wed Jun 21, 2017 08:00 PM
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 (fw): Select all Collapse
//  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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Thu Jun 22, 2017 05:23 PM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Fri Jun 23, 2017 01:39 PM
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



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



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




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 (fw): Select all Collapse
 //  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 )
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Fri Jun 23, 2017 03:13 PM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Fri Jun 23, 2017 03:42 PM
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 (fw): Select all Collapse
//----------------
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.)
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Fri Jun 23, 2017 03:51 PM

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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao ).. SOLVED
Posted: Fri Jun 23, 2017 03:57 PM
The best way is to test with as small program as possible
I am testing with this program
Code (fw): Select all Collapse
#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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Fri Jun 23, 2017 04:04 PM

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

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Fri Jun 23, 2017 04:52 PM
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

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Mon Jun 26, 2017 07:37 PM

Rao

Any News ?

Thanks
Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Tue Jun 27, 2017 04:16 AM

Mr Rick
I need some more time please

Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Thu Jul 13, 2017 02:33 PM

Rao

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

Thanks
Rick Lipkin

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Tue Jul 25, 2017 12:25 PM

Rao

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

Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Sat Jul 29, 2017 04:32 PM
Sorry for the delay.

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

Modify this line as
Code (fw): Select all Collapse
      case nKey == VK_RETURN .or. nKey == VK_TAB


Please let us know the result
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse TAB vs ENTER key EDIT_GET ( rao )
Posted: Mon Jul 31, 2017 02:17 PM

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