Xbrowse EDIT_GET_BUTTON overwrite manual data

Xbrowse EDIT_GET_BUTTON overwrite manual data

Postby Marc Venken » Thu Oct 27, 2016 10:23 pm

Hello,

In my Xbrowse (the first = oData) i have on field 2 a edit_get_button to select from a dropdown a field. That Works ok.
When I manualy want to type something, it will alsways be overwritten by the value a the button get.
The code says to do that : (from samples)

:bOnChange := { |oCol,uOldVal| oData:FieldValue:VarPut( PRD->VELD ) }

But I want it only when I use the button, not when entering data by keybaord.
I need to be able to type data or push the button to select from the dropdown.

Regards
Marc

Code: Select all  Expand view

FUNCTION master()

   local oDlg, oData, oStru, oFont, aDbf[ADIR("*.dbf")]
   local nProgClr := RGB( 161, 224, 255 )
   local nSelectedRow

   ADIR("*.dbf", aDbf)
   nFile = msglist(aDbf )
   cDbf = aDbf[nFile]

   USE struct new ALIAS PRD

   USE master NEW ALIAS MASTER
   if Select( "MASTER" ) == 0
      MsgStop( "Can not open MasterFile.DBF" )
      return 1
   endif

   USE &cDbf NEW ALIAS CUST
   if Select( "CUST" ) == 0
      MsgStop( "Can not open File.DBF" )
      return 1
   endif

   dbselectarea("CUST")

   for i = 1 to CUST->(FCOUNT())
      PRD->(dbappend())
      replace PRD->id with i
      replace PRD->veld with Fieldname(i)      // len en valtype
   next


   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg SIZE 2*WID,2*HGT PIXEL FONT oFont

   @ 10,10 XBROWSE oData SIZE 200,320 PIXEL OF oDlg ;
      DATASOURCE MASTER->( DbStruct() ) ;
      COLUMNS 1, ;
      { |x| If( x == nil, MASTER->( FieldGet( oData:nArrayAt ) ), ;
         MASTER->( If( DbRLock(), ( FieldPut( oData:nArrayAt, x ), DbRUnLock() ), nil ) ) ) } ;
      HEADERS "FldName","FieldValue" ;
      COLSIZES 120,250 ;
      AUTOCOLS CELL LINES FASTEDIT

   @ 10,220 XBROWSE oStru SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE CUST->( DbStruct() ) ;
      COLUMNS 1,2,3,4, ;
      { |x| If( x == nil, CUST->( FieldGet( oStru:nArrayAt ) ), ;
         CUST->( If( DbRLock(), ( FieldPut( oStru:nArrayAt, x ), DbRUnLock() ), nil ) ) ) } ;
      HEADERS "FldName","Typ","Len","Dec", "FieldValue" ;
      COLSIZES 120,40,40,40,400 ;
      AUTOCOLS CELL LINES FASTEDIT

   oData:lRecordSelector := .T.

   WITH OBJECT oData

      WITH OBJECT :oCol( 2 )
         :nEditType     := EDIT_GET_BUTTON
         :bClrSel          := { || { CLR_BLACK, CLR_HGRAY }}

         :bEditBlock    := { |r,c,oCol| ProductSelect( oCol:Value ) }
         :bOnChange     := { |oCol,uOldVal| oData:FieldValue:VarPut( PRD->VELD ) }

      ENDWITH
      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW }}
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      :CreateFromCode()
   END

   WITH OBJECT oStru
      :bClrSel          := { || { CLR_BLACK, CLR_HGRAY }}

      //
      WITH OBJECT :aCols[ 5 ]
         :bClrEdit      := { || { CLR_BLACK, CLR_YELLOW }}
      END

      //
      :CreateFromCode()
   END

   oStru:aCols[5]:bClrStd := { || IF( PRD->(deleted()) , { CLR_WHITE,CLR_HRED } , { CLR_BLUE,CLR_WHITE } ) }

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
   select master
   xbrowse()
   close all
return 0

 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Xbrowse EDIT_GET_BUTTON overwrite manual data

Postby nageswaragunupudi » Fri Oct 28, 2016 12:48 am

You should not be using bOnChange at all.

bEditBlock should return the value to be assigned if the user selects else nil.

Example:

oCol:bEditBlock := { || PRD->VELD }
Remove bOnChange
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Xbrowse EDIT_GET_BUTTON overwrite manual data

Postby Marc Venken » Sun Oct 30, 2016 8:51 am

This worked.

Thank you.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

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