XBrowse: Using Get for incremental Seek/Filters
Posted: Wed Dec 09, 2020 12:20 am
We use a SAY control to display text entered by the user for incremental seek/filter like this:
There are situations when the programmer prefers to use a GET control for input of search expression. But in the present implementation, this is not supported by xbrowse.
In the version under release, this is made very simple.
Sample:
When Get has the focus, the text entered by the user is used for the incremental search/filter. If the search/filter fails, the user's keystroke is discarded.
When the browse has focus, the user can continue entering further characters and the Get is updated correctly.
The user can alternate between Get and Browse retaining the continuity.
Notes:
1) Create the Get using a different variable (eg: oGet) but not oBrw:oSeek and use a different variable with adequate width but not oBrw:cSeek as in the above example.
2) Assign oBrw:oSeek := oGet, before calling oBrw:CreateFromCode().
3) Use character variable irrespective of the data type of the search field.
4) Do not define bChange or bKeyDown or bKeyChar for the Get. XBrowse automatically creates necessary codeblocks. Keep the application code as simple as shown in the above sample.
Code: Select all
@ r, c SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE w,h PIXEL OF oDlg
In the version under release, this is made very simple.
Sample:
Code: Select all
#include "fivewin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
local oDlg, oGet, oBrw
local cSeek := Space( 100 )
SetGetColorFocus()
FERASE( "CUSTOMER.CDX" )
USE CUSTOMER NEW EXCLUSIVE VIA "DBFCDX"
FW_CdxCreate()
SET ORDER TO TAG FIRST
GO TOP
DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL
@ 20,20 GET oGet VAR cSeek SIZE 460,20 PIXEL OF oDlg
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE "CUSTOMER" ;
AUTOCOLS AUTOSORT CELL LINES NOBORDER
WITH OBJECT oBrw
:lIncrFilter := .t.
:oSeek := oGet // Required before :CreateFromCode()
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
return nil
When the browse has focus, the user can continue entering further characters and the Get is updated correctly.
The user can alternate between Get and Browse retaining the continuity.
Notes:
1) Create the Get using a different variable (eg: oGet) but not oBrw:oSeek and use a different variable with adequate width but not oBrw:cSeek as in the above example.
2) Assign oBrw:oSeek := oGet, before calling oBrw:CreateFromCode().
3) Use character variable irrespective of the data type of the search field.
4) Do not define bChange or bKeyDown or bKeyChar for the Get. XBrowse automatically creates necessary codeblocks. Keep the application code as simple as shown in the above sample.