STATIC FUNCTION AutoEdit( oWnd )
local oChild, oBrw, oCol
local nFor
DEFINE WINDOW oChild TITLE "Auto edit browse" MDICHILD OF oWnd
oBrw := TXBrowse():New( oWnd )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oBrw:SetRDD()
for nFor := 1 to len( oBrw:aCols )
oCol := oBrw:aCols[ nFor ]
oCol:nEditType := 1
oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, FieldPut( o:nCreationOrder, v ), ) }
next
oBrw:CreateFromCode()
oChild:oClient := oBrw
oBrw:bPastEof() := {||msginfo("APND")} // ADDED !!!!!!!!!!!!
ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()
RETURN
#include 'fivewin.ch'
#include 'xbrowse.ch'
//----------------------------------------------------------------------------//
function Main()
local oWnd, oBrw
SET DELETED ON
use sales alias test
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw ;
ALIAS 'TEST' ;
AUTOCOLS ;
FASTEDIT
AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )
// oBrw:bPastEof := {||msginfo("APND")}
oBrw:bPastEof := { || AddRec( oBrw ) }
oBrw:bOnRowLeave := { || RowLeave( oBrw ) }
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
static function AddRec( oBrw )
local nRec
if Empty( ( oBrw:cAlias )->Date )
// We have already appended a blank record
// user is still to edit the record
// so we should not append one more record
// Avoid responding to repeated multiple calls
// Take no action.
else
nRec := ( oBrw:cAlias )->( RecNo() )
( oBrw:cAlias )->( dbAppend(), dbGoTo( nRec ) )
oBrw:GoDown() // note this works when dbf is not in any index order
// otherwise we need to code it differently
oBrw:lEdited := .t.
endif
return nil
//----------------------------------------------------------------------------//
static function RowLeave( oBrw )
if Empty( ( oBrw:cAlias )->Date ) .and. ;
( oBrw:cAlias )->( RecNo() ) == ( oBrw:cAlias )->( LastRec() )
// We are now leaving the last record just appended
// user has not filled any valid data
// we need to delete this record
( oBrw:cAlias )->( DbDelete() )
oBrw:Refresh()
endif
return nil
//----------------------------------------------------------------------------//
#include 'fivewin.ch'
#include 'xbrowse.ch'
function Main()
local oChild, oBrw, oCol
local nFor
use sales alias test
DEFINE WINDOW oWnd TITLE "Auto edit browse"
oBrw := TXBrowse():New( oWnd )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oBrw:SetRDD()
for nFor := 1 to len( oBrw:aCols )
oCol := oBrw:aCols[ nFor ]
oCol:nEditType := 1
oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, FieldPut( o:nCreationOrder, v ), ) }
next
oBrw:CreateFromCode()
oWnd:oClient := oBrw
oBrw:bPastEof := {|| PastEOF() } // ADDED !!!!!!!!!!!!
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()
RETURN nil
static function PastEOF()
static lShown
if Empty( lShown ) .or. ! lShown
lShown = .T.
MsgInfo( "APND" )
lShown = .F.
endif
return nil
nageswaragunupudi wrote:If we keep pressing the down arrow of the vertical scroll bar, method godown is executed so many times and naturally the bPastEof is evaluated as many times as we keep the arrow button pressed. I think we need to expect this.
METHOD GoDown() CLASS TXBrowse
local nLines
if ::nLen == 0 .or. Eval( ::bEof, Self )
if ::bPastEof != nil
# ifdef FRANKDEMONT
IF PROCNAME(1) <> "TXBROWSE:VSCROLL"
Eval( ::bPastEof )
END
# else
Eval( ::bPastEof )
# endif
endif
return nil
endif
::CancelEdit()
::Seek()
nLines := ::RowCount()
::DrawLine()
if Eval( ::bSkip, 1, Self ) == 1
if ::nRowSel < nLines
::nRowSel++
else
//XBrwScroll( ::hWnd, 1, ::nRowHeight, ::nHeaderHeight , ::nFooterHeight )
XBrwScr2( ::hWnd, ::nRowHeight, ::HeaderHeight(), nLines * ::nRowHeight )
endif
if ::bChange != nil
Eval( ::bChange, Self, .t. )
endif
if ::oVScroll != nil
::VGoDown()
endif
else
if ::bPastEof != nil
# ifdef FRANKDEMONT
IF PROCNAME(1) <> "TXBROWSE:VSCROLL"
Eval( ::bPastEof )
END
# else
Eval( ::bPastEof )
# endif
//Eval( ::bPastEof, Self )
endif
if ::oVScroll != nil
::VGoBottom()
endif
endif
::DrawLine( .t. )
return nil
nageswaragunupudi wrote:>>
>>>>
# ifdef FRANKDEMONT
IF PROCNAME(1) <> "TXBROWSE:VSCROLL"
Eval( ::bPastEof )
END
# else
Eval( ::bPastEof )
# endif
>>>>
This means, pressing down arrow button on vertial scroll bar does not evaluate bPostEof.
Still pressing Down Arrow does call bpasteof, each time the user presses.
Assuming we append a record and offer inline editing ( not in a separate dialog ), the user can again press down arrow and do we append another record?
For that reason, I personally feel that the right place to avoid responding to second and subsequent ( 'click' of button or pressing down arrow) calls is our bPastEof codeblock till the intended append is finished or cancelled.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 88 guests