if ::bEditValid != nil
::oEditGet:bValid := ::bEditValid
endif
if ::bEditValid != nil
::oEditGet:bValid := { | oGet, lRet | ::oEditGet:lValidating := .T., lRet := Eval( ::bEditValid, oGet ), ::oEditGet:lValidating := .F., lRet }
endif
::oEditGet:bLostFocus := { || ::PostEdit() }
::oEditGet:bLostFocus := { || If( ! ::oEditGet:lValidating, ::PostEdit(),) }
if ::bEditValid != nil
::oEditGet:bValid := { | oGet, lRet | ::oEditGet:lValidating := .T., lRet := Eval( ::bEditValid, oGet ), ::oEditGet:lValidating := .F., If( ! lRet, ::oEditGet:SetFocus(),), lRet }
endif
::oEditGet:bLostFocus := { || If( ::oEditGet != nil .and. ! ::oEditGet:lValidating, ::PostEdit(),) }
METHOD CancelEdit() CLASS TXBrowse
local oCol, nFor, nlen
if ! ::lEditMode
return nil
endif
nLen := Len( ::aCols )
for nFor := 1 to nLen
oCol := ::aCols[ nFor ]
if oCol:oEditGet != nil
oCol:oEditGet:VarPut( Eval( oCol:bEditValue ) )
oCol:oEditGet:bValid = nil
oCol:PostEdit()
endif
next
::lEditMode := .f.
return nil
if ::oEditGet != nil .or. ::oEditLbx != nil .or. ::oBrw:nLen == 0
return nil
endif
if ( ::oEditGet != nil .and. nRow == ::oBrw:nRowSel ) .or. ::oEditLbx != nil .or. ::oBrw:nLen == 0
return nil
endif
static function EditGetkeyDown( Self, nKey )
...
case nKey == VK_ESCAPE
lExit := .t.
::oEditGet:bValid = nil
...
# INCLUDE "FiveWin.ch"
# INCLUDE "XBrowse.ch"
//-------------
FUNCTION Main()
//-------------
LOCAL oWnd,aLin:={},i,oBrw
FOR i:=1 TO 6
AAdd(aLin,{i,'Descripción '+Str(i)})
NEXT
DEFINE WINDOW oWnd
//--Definición Objeto TxBrowse
oBrw:=TxBrowse():New(oWnd)
oBrw:SetArray(aLin)
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:aCols[1]:cHeader := 'Cod'
oBrw:aCols[1]:cEditPicture := '@k 99'
oBrw:aCols[1]:bClrEdit := oBrw:bClrStd
oBrw:aCols[1]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,1] := xVal,) }
oBrw:aCols[1]:nEditType := EDIT_GET
oBrw:aCols[1]:bEditValid := { | oGet | Valida( oGet ) } //<========
//--
oBrw:aCols[2]:cHeader := 'Descripción'
oBrw:aCols[2]:bClrEdit := oBrw:bClrStd
oBrw:aCols[2]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,2] := xVal,) }
oBrw:aCols[2]:nEditType := EDIT_GET
//--
oBrw:CreateFromCode()
oBrw:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oBrw, aLin ) }
oWnd:oClient:=oBrw
ACTIVATE WINDOW oWnd
RETURN NIL
STATIC FUNCTION Valida( oGet )
IF oGet:Value() > 6
MsgAlert( "Must be lower than 7" )
return .F.
ENDIF
RETURN .T.
function ShowPopup( nRow, nCol, oBrw, aLin )
local oMenu
MENU oMenu POPUP
MENUITEM "Add" ACTION ( AAdd( aLin, { AllTrim( Str( Len( aLin ) + 1 ) ), "New item" } ), oBrw:SetArray( aLin ), oBrw:Refresh() )
MENUITEM "Del" ACTION ( ADel( aLin, oBrw:nArrayAt ), ASize( aLin, Len( aLin ) - 1 ), oBrw:SetArray( aLin ), oBrw:Refresh() )
MENUITEM "Select" ACTION ( oBrw:GoTop(), oBrw:nArrayAt := 3, oBrw:Refresh() )
ENDMENU
ACTIVATE POPUP oMenu WINDOW oBrw AT nRow, nCol
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 76 guests