Test for Vertical Scroll hits EOF xBrowse ( rao )

Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Thu Jan 18, 2018 5:59 pm

Rao

I have an invoicing module that uses the code block bPastEof to trigger the AddNewRow function ..
Code: Select all  Expand view

 // add a new record
          oLbxB:bPastEof = {|| _AddNewRow( oRsDetail,nRepairNumber,nAssignedTo,cLoc,oLbxB,"Y",oRsRepair,"" ) }
 

What I have tried to do is add a MsgYesNo() at the top of AddNewRow() to ask the user if they ( really ) want to add a new Row to stop a run-away multiple add new blank rows.
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

// create new row and primary key
 

Unfortunately, some of my users use the vertical scroll bar or the mouse wheel to move through the itemized rows and when the mouse wheel or vertical scroll bar hits bPastEof .. it triggers multiple calls to AddNewRow()

I have tried to trap the input and I want to let the DOWN ARROW KEY ONLY to fire the bPastEof :
Code: Select all  Expand view

          oLbxB:bKeyDown := { |nKey| if(nKey = VK_DOWN,  _AddNewRow( oRsDetail,nRepairNumber,nAssignedTo,cLoc,oLbxB,"Y",oRsRepair,"") , )}
          oLbxB:bKeyChar := { |nKey| MsgInfo(nKey) }

          // add a new record
          oLbxB:bPastEof = {|| _AddNewRow( oRsDetail,nRepairNumber,nAssignedTo,cLoc,oLbxB,"Y",oRsRepair,"" ) }
 


Unfortunitly the bKeyDown or bKeyChar block does not fire and I can not prevent the screen shot you see below... Any advice would be helpful!

Thanks
Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Fri Jan 19, 2018 8:45 pm

Up please
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby nageswaragunupudi » Fri Jan 19, 2018 9:22 pm

We need to have an internal flag to know if the new row si written or not.
I will give here a sample of how do I do that. Please wait for a little while.
Regards

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

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Sat Jan 20, 2018 4:18 pm

Rao

Interesting idea ... however ... I only want the AddNewRow() to fire when arrow down hits bEof .. when a user scrolls down the vertical bar .. they hit the bEof code block multiple times ..same for the mouse wheel and I end up with a mess.

If there was only a way to trap the down arrow key .. I could ignore all the other random inputs.... interested to see your idea and I am not in any big hurry. I appreciate your help!

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Sat Feb 03, 2018 4:26 pm

Rao

Just wanted to keep this on your radar scope ... thanks, Rick
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Thu Feb 08, 2018 7:05 pm

Rao

I have been trying to create a variable that passes to AddNewRow() and I can trap the increment .. however the oLbxB:bPastEof code block keeps firing in a non modal mode ...

Any help would be appreciated.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby nageswaragunupudi » Thu Feb 08, 2018 11:37 pm

Please try this sample:
Code: Select all  Expand view
#include "fivewin.ch"
#include "adodef.ch"

static oCn
static cTable := "testappend"

//----------------------------------------------------------------------------//

function Main()

   SetGetColorFocus()
   FWNumFormat( "A", .t. )

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      ? "Connect Fail"
      return nil
   endif

   if .not. FW_AdoTableExists( cTable, oCn )
      CreateTestTable()
   endif

   EditTable()

   oCn:Close()

return nil

//----------------------------------------------------------------------------//

function CreateTestTable()

   local aCols := { { "ITEM", "C", 10, 0 }, { "AMOUNT", "N", 12, 2 } }
   local aData := { { "One", 1000 }, { "Two", 2000 }, { "Three", 3000 } }
   local oRs

   ? "Creating Table"

   FWAdoCreateTable( cTable, aCols, oCn )

   // Add sample record
   oRs   := FW_OpenRecordSet( oCn, cTable )
   AEval( aData, { |a| oRs:AddNew( { "item", "amount" }, a ) } )
   oRs:Close()

return nil

//----------------------------------------------------------------------------//

function EditTable()

   local oRs
   local oDlg, oFont, oBrw
   local lAppending := .f.

   oRs   := FW_OpenRecordSet( oCn, cTable, adLockBatchOptimistic )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      COLSIZES "9999" ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nStretchCol      := STRETCHCOL_WIDEST
      :nEditTypes       := EDIT_GET
      :bSaveData        := { || oBrw:oRs:UpdateBatch(), lAppending := .f. }
      :bPastEof         := { || If( lAppending, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
      :bKeyDown         := { |k| If( k == VK_DELETE, ( oBrw:Delete(), lAppending := .f., 0 ), nil ) }
      :bClrStd          := { || { CLR_BLACK, If( oBrw:oRs:Status == 1, 0xffff80, CLR_WHITE ) } }
      //
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:CancelBatch()
   oRs:Close()

return nil

//----------------------------------------------------------------------------//
 
Regards

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

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Fri Feb 09, 2018 6:43 pm

Rao

Thank you for your sample .. I have two problems

1) eof can occur with the vertical scroll bar
2) eof can occur with the down arrow key

In your example .. both scenarios create a new row and your logic works .. however, in the repair business there may be 20 or 30 lines of detail on an invoice and the typical technician uses the vertical scroll bar to pan down thru all the rows ... and when the scroll bar hits EOF .. I was getting the run-away addnewrow.

Your code solves the run-away addnewrow problem.. but when the vertical scrollbar hits EOF .. it creates 1 new empty row .. which is much better than creating 30 new rows ..

What ultimately I wanted to do is be able to trap the down arrow key only at the Eof code-block and ignore any other inputs such as the vertical scroll bar. Inspired by your code I made two changes .. one to xBrowse.prg and the other to your code ..

Please consider this change to xBrowse METHOD KeyDown to allow the key value to be returned. This change allows me to test for bKeyDown and the down arrow key. I do know know if making this small code change would have any un-intended consequences ..

Please review my solution .. if there is another way to prevent the verticle scroll bar from tripping the eof code block, I am open to any ideas.

Thanks
Rick Lipkin

Code: Select all  Expand view

// xbrowse.prg

METHOD KeyDown
...
...
...


 case nKey == VK_DOWN .and. !GetKeyState( VK_CONTROL )

       if ::KeyNo == ::nLen .and. Empty( ::bPastEof ) .and. ::lRelyOnKeyNo
         return 0
      endif
      ::Select( 0 )
      ::GoDown()
      ::Select( 1 )

      return ::Super:KeyDown( nKey, nFlags )   // proposed change rlipkin 02/09/2018

 


With the above changes I have modified your code as follows:
Code: Select all  Expand view

#include "fivewin.ch"
#include "adodef.ch"

static oCn
static cTable := "testappend"

//----------------------------------------------------------------------------//

function Main()

   SetGetColorFocus()
   FWNumFormat( "A", .t. )

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      ? "Connect Fail"
      return nil
   endif

   if .not. FW_AdoTableExists( cTable, oCn )
      CreateTestTable()
   endif

   EditTable()

   oCn:Close()

return nil

//----------------------------------------------------------------------------//

function CreateTestTable()

   local aCols := { { "ITEM", "C", 10, 0 }, { "AMOUNT", "N", 12, 2 } }
   local aData := { { "One", 1000 }, { "Two", 2000 }, { "Three", 3000 } }
   local oRs

   ? "Creating Table"

   FWAdoCreateTable( cTable, aCols, oCn )

   // Add sample record
   oRs   := FW_OpenRecordSet( oCn, cTable )
   AEval( aData, { |a| oRs:AddNew( { "item", "amount" }, a ) } )
   oRs:Close()

return nil

//----------------------------------------------------------------------------//

function EditTable()

   local oRs
   local oDlg, oFont, oBrw
   local lAppending := .f.

   oRs   := FW_OpenRecordSet( oCn, cTable, adLockBatchOptimistic )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      COLSIZES "9999" ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nStretchCol      := STRETCHCOL_WIDEST
      :nEditTypes       := EDIT_GET
      :bSaveData        := { || oBrw:oRs:UpdateBatch(), lAppending := .f. }
     * :bPastEof         := { || If( lAppending, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
     
       // code changes here to test for the down arrow key to trap eof -----------------------------------------------------
       :bPastEof         := { ||  oBrw:bKeyDown := { |nKey| if(nKey = VK_DOWN,;
                               (if(MsgYesNo("Add New Row?"),(oBrw:oRs:AddNew(),lAppending := .t.,oBrw:ReFresh()),)),)}}
       //--------------------------------------------------------------------------------------------------------------------------

       :bKeyDown         := { |k| If( k == VK_DELETE, ( oBrw:Delete(), lAppending := .f., 0 ), nil ) }

       :bClrStd          := { || { CLR_BLACK, If( oBrw:oRs:Status == 1, 0xffff80, CLR_WHITE ) } }
      //
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:CancelBatch()
   oRs:Close()

return nil

//----------------------------------------------------------------------------//
 
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby nageswaragunupudi » Sat Feb 10, 2018 1:15 am

From FWH1801, bPastEof will be evaluated with 2 parameters viz., Self, nKey.
nKey can be nil, VK_DOWN, 0 or -1 depending on the triggering event.

Code: Select all  Expand view

VK_DOWN : When triggered by pressing down key by the user.
0      : If ::GoDown() is called by the application program or triggered by any event other than down key, when the table is Empty.
1      : After last column of last row is edited in FastEdit mode, if ::lAutoAppend is .T. ( default)
nil    : Any other case.
 


Typically, a programmer would like to insert a new row only if nKey != nil and is not already appending

bPastEof would look like this:
Code: Select all  Expand view
:bPastEof         := { |o,k| If( lAppending .or. k == nil, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
Regards

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

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby nageswaragunupudi » Sat Feb 10, 2018 2:07 am

There are some bugs in the code posted above by me.
This is a revised code:
Code: Select all  Expand view
#include "fivewin.ch"
#include "adodef.ch"

static oCn
static cTable := "testappend"

//----------------------------------------------------------------------------//

function Main()

   SetGetColorFocus()
   FWNumFormat( "A", .t. )

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      ? "Connect Fail"
      return nil
   endif

   if .not. FW_AdoTableExists( cTable, oCn )
      CreateTestTable()
   endif

   EditTable()

   oCn:Close()

return nil

//----------------------------------------------------------------------------//

function CreateTestTable()

   local aCols := { { "ITEM", "C", 10, 0 }, { "AMOUNT", "N", 12, 2 } }
   local aData := { { "One", 1000 }, { "Two", 2000 }, { "Three", 3000 } }
   local oRs

   ? "Creating Table"

   FWAdoCreateTable( cTable, aCols, oCn )

   // Add sample record
   oRs   := FW_OpenRecordSet( oCn, cTable )
   AEval( aData, { |a| oRs:AddNew( { "item", "amount" }, a ) } )
   oRs:Close()

return nil

//----------------------------------------------------------------------------//

function EditTable()

   local oRs
   local oDlg, oFont, oBrw
   local lAppending := .f.

   oRs   := FW_OpenRecordSet( oCn, cTable, adLockBatchOptimistic )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      COLSIZES "9999" ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nStretchCol      := STRETCHCOL_WIDEST
      :nEditTypes       := EDIT_GET
      :bSaveData        := ;
         <||
         if oBrw:oRs:Status == 1
            oBrw:oRs:UpdateBatch()
            lAppending := .f.
         elseif lAppending
            oBrw:oRs:Update()
         else
            oBrw:oRs:UpdateBatch()
         endif
         return nil
         >
      // FWH1801 onwards
      :bPastEof         := { |o,k| If( lAppending .or. k == nil, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
      // Upto FWH1712
      //:bPastEof         := { || If( lAppending, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
      :bKeyDown         := { |k| If( k == VK_DELETE, ( oBrw:Delete(), lAppending := .f., 0 ), nil ) }
      :bClrStd          := { || { CLR_BLACK, If( oBrw:oRs:Status == 1, 0xffff80, CLR_WHITE ) } }
      //
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   if lAppending
      oRs:MoveLast()
      if oRs:Status == 1
         oRs:Delete()
         oRs:MoveLast()
      endif
   endif
   oRs:UpdateBatch()
   oRs:Close()

return nil

//----------------------------------------------------------------------------//
 
Regards

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

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Sat Feb 10, 2018 2:36 pm

Rao

I am using FWH1707 and your sample runs for my version... however, I only want to trigger a new record at Eof by using the down arrow key ( only ) .. Your samples allow for a new record to be triggered by any mechanism that forces the record pointer past eof. ( e.g. Down Arrow or vertical scroll bar )

SO if I were using FWH1801 .. I could indeed trap only the VK_DOWN key ?
Code: Select all  Expand view

// FWH1801 onwards
      :bPastEof         := { |o,k| If( lAppending .or. k == nil, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
 

I don't seem to follow the logic .. so how would you know in the above example if VK_DOWN was the last and only key that tripped eof?

if ( lAppending .and. k = VK_DOWN ), oBrw:oRs:AddNew() ......, ) ?

As I mentioned .. My invoicing routine may have 30-50 lines .. and technicians routinely use the vertical scroll bar to pan through the invoice rows and when the vertical scroll bar hits eof .. a new row is created which then has to be deleted.

Here is your 1707 suggested code that created the below effect ... with the vertical scroll bar.
Code: Select all  Expand view

 // Upto FWH1712
      :bPastEof         := { || If( lAppending, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
 


Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby nageswaragunupudi » Sat Feb 10, 2018 4:52 pm

SO if I were using FWH1801 .. I could indeed trap only the VK_DOWN key ?

yes
Regards

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

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Sat Feb 10, 2018 5:15 pm

Rao

GREAT!! just curious how you would code that?

Code: Select all  Expand view

// FWH1801 onwards
      :bPastEof         := { |o,k| If( lAppending .or. k == nil, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }
 


Code: Select all  Expand view

      :bPastEof         := { |o,k|  if( lAppending .and. k = VK_DOWN ), oBrw:oRs:AddNew() ......, ) ?
 


Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby nageswaragunupudi » Sat Feb 10, 2018 5:46 pm

Please try this improved code:
Code: Select all  Expand view
#include "fivewin.ch"
#include "adodef.ch"

static oCn
static cTable := "testappend"

//----------------------------------------------------------------------------//

function Main()

   SetGetColorFocus()
   FWNumFormat( "A", .t. )

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      ? "Connect Fail"
      return nil
   endif

   if .not. FW_AdoTableExists( cTable, oCn ) .or. ;
      MsgYesNo( "Create Table again?" )
      CreateTestTable()
   endif

   EditTable()

   oCn:Close()

return nil

//----------------------------------------------------------------------------//

function CreateTestTable()

   local aCols := { { "ITEM", "C", 10, 0 }, { "AMOUNT", "N", 12, 2 } }
   local aData := { { "One", 1000 }, { "Two", 2000 }, { "Three", 3000 } }
   local oRs

   ? "Creating Table"

   oCn:Execute( "DROP TABLE " + cTable )

   FWAdoCreateTable( cTable, aCols, oCn )
/*
   // Add sample record
   oRs   := FW_OpenRecordSet( oCn, cTable )
   AEval( aData, { |a| oRs:AddNew( { "item", "amount" }, a ) } )
   oRs:Close()
*/


return nil

//----------------------------------------------------------------------------//

function EditTable()

   local oRs
   local oDlg, oFont, oBrw
   local nAppendRec   := nil

   oRs   := FW_OpenRecordSet( oCn, cTable, adLockBatchOptimistic )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      COLSIZES "9999" ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nStretchCol      := STRETCHCOL_WIDEST
      :nEditTypes       := EDIT_GET
      :bSaveData        := ;
         <||
         WITH OBJECT oBrw:oRs
            if :Status == 1
               :UpdateBatch()
               nAppendRec  := nil
            elseif Empty( nAppendRec )
               :UpdateBatch()
            else
               :Update()
            endif
         END
         return nil
         >
      // FWH1801 onwards
      :bPastEof         := ;
         <|o,nKey|
         if Empty( nAppendRec ) .and. nKey != nil
            o:oRs:AddNew()
            nAppendRec  := o:oRs:BookMark
            o:Refresh()
         endif
         return nil
         >
      // Upto1712
      :bPastEof         := ;
         <|o|
         if Empty( nAppendRec )
            o:oRs:AddNew()
            nAppendRec  := o:oRs:BookMark
            o:Refresh()
         endif
         return nil
         >
      :bKeyDown         := { |k| If( k == VK_DELETE, ( oBrw:Delete(), nAppendRec := nil, 0 ), nil ) }
      :bChange          := ;
         <||
         local nSaveBM
         if !Empty( nAppendRec ) .and. oBrw:oRs:Status != 1
            nSaveBM     := oBrw:oRs:BookMark
            oBrw:oRs:BookMark := nAppendRec
            oBrw:oRs:Delete()
            oBrw:oRs:BookMark := nSaveBM
            oBrw:oRs:UpdateBatch()
            nAppendRec   := nil
            oBrw:Refresh()
         endif
         return nil
         >
      :bClrStd          := { || { CLR_BLACK, If( oBrw:oRs:Status == 1, 0xffff80, CLR_WHITE ) } }
      //
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   if !Empty( nAppendRec )
      oRs:BookMark   := nAppendRec
      if oRs:Status == 1
         oRs:Delete()
         if oRs:RecordCount() > 0
            oRs:MoveLast()
         endif
      endif
   endif
   oRs:UpdateBatch()
   oRs:Close()

return nil

//----------------------------------------------------------------------------//
 

This works well with empty tables also.
Uparrow from record under append removes the new record.
Regards

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

Re: Test for Vertical Scroll hits EOF xBrowse ( rao )

Postby Rick Lipkin » Sat Feb 10, 2018 6:44 pm

Rao

It is time for me to upgrade anyway .. for now I have copied my modified xBrowse.prg to my project with the modified METHOD KeyDown ... I noticed your new code ... just curious how you would modify your code to trap vk_down with FWH1801 or greater ?

From FWH1801, bPastEof will be evaluated with 2 parameters viz., Self, nKey.
nKey can be nil, VK_DOWN, 0 or -1 depending on the triggering event.

Code:

VK_DOWN : When triggered by pressing down key by the user.
0 : If ::GoDown() is called by the application program or triggered by any event other than down key, when the table is Empty.
1 : After last column of last row is edited in FastEdit mode, if ::lAutoAppend is .T. ( default)
nil : Any other case.



Typically, a programmer would like to insert a new row only if nKey != nil and is not already appending

bPastEof would look like this:
Code:
:bPastEof := { |o,k| If( lAppending .or. k == nil, nil, ( oBrw:oRs:AddNew(), lAppending := .t., oBrw:Refresh() ) ) }


Obviously you will have to evaluate K for the Keydown ... something like this ?
Code: Select all  Expand view

:bPastEof := { |o,k|if ( lAppending .and. k = VK_DOWN ), oBrw:oRs:AddNew() ......, ) ?
 


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

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