DCGETBROWSE

This forum is for eXpress++ general support.
Message
Author
User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

DCGETBROWSE

#1 Post by unixkd »

Hi Roger/All

How can I make the command below to have other parameter like:

#command DCGETBROWSE [DATA <d>] [GET <g>] => GetBrowse( <d>, @<g>, GetList )

Example:

Code: Select all

#command DCGETBROWSE [DATA <d>] [GET <g>] => GetBrowse( <d>, @<g>, GetList, aColSize, aColHead, aColWidth) 

FUNCTION GetBrowse( aData, oGet, GetList, aColSize, aColHead, aColWidth )

LOCAL nPointer, oBrowse, oStatic

@ DCGUI_ROW, DCGUI_COL DCPUSHBUTTON SIZE 20,20 PIXEL ;
      CAPTION 'u' FONT '12.Marlett' ;
      ACTION {||PostAppEvent(xbeP_Keyboard,xbeK_SH_DOWN,,oGet)} ;
      NOTABSTOP

@ 0,0 DCSTATIC OBJECT oStatic TYPE XBPSTATIC_TYPE_TEXT SIZE 10,10 ;
      INVISIBLE

@ 0,0 DCBROWSE oBrowse DATA aData ;
       PARENT oStatic ;
       NOTABSTOP ;
       SIZE 10,10 ;
       NOHSCROLL ;
       POINTER nPointer ;
       ITEMSELECTED {||oGet:setData(Pad(aData[nPointer,1],20)), ;
                     DC_GetRefresh(oGet), ;
                     oStatic:hide(), ;
                     SetAppFocus(oGet)} ;
       LOSTFOCUS {|a,b,o|o:hide()}

DCBROWSECOL ELEMENT 1 WIDTH 16 PARENT oBrowse

DCEVAL {||oStatic:setPos({oGet:currentPos()[1], ;
                          oGet:currentPos()[2]-oStatic:currentSize()[2]}), ;
          oStatic:setSize({oGet:currentSize()[1]+15,oStatic:currentSize()[2]}), ;
          oBrowse:setSize(oStatic:currentSize()), ;
          oGet:setInputFocus := {||oStatic:hide()}, ;
          oGet:keyboard := {|nKey,b,oGet|SeekFile(aData,nKey,oGet,oBrowse,oStatic)} }

RETURN nil

STATIC FUNCTION SeekFile( aDir, nKey, oGet, oBrowse, oStatic )

LOCAL nFound, cBuffer := Trim(oGet:get:buffer)

IF nKey == xbeK_BS .OR. nKey == xbeK_DEL .OR. nKey == xbeK_TAB
  RETURN nil
ELSEIF nKey == xbeK_SH_DOWN
  oStatic:show()
  oStatic:toFront()
  oBrowse:show()
  oBrowse:forceStable()
  oBrowse:refreshAll()
  SetAppFocus(oBrowse)
  RETURN nil
ELSEIF nKey == xbeK_DOWN .AND. oStatic:isVisible()
  SetAppFocus(oBrowse)
  RETURN nil
ENDIF

IF nKey == xbeK_ENTER
  IF oStatic:isVisible()
    PostAppEvent(xbeBRW_ItemSelected,,,oBrowse)
  ENDIF
  RETURN nil
ENDIF

IF !Empty(cBuffer)
  nFound := AScan(aDir,{|a|a[1]=cBuffer})
  IF nFound > 0
    oBrowse:arrayElement := nFound
    oBrowse:refreshAll()
    oStatic:show()
    oStatic:toFront()
    oBrowse:show()
  ENDIF
ELSE
  oStatic:hide()
ENDIF

RETURN nil

)

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCGETBROWSE

#2 Post by rdonnay »

I don't understand your question.

Are you saying that you want to add 3 more parameters? aColSize, aColHead, aColWidth
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCGETBROWSE

#3 Post by unixkd »

Yes, exactly so that we can have a multi-column browse with possibility of browse header and corresponding column width.

It will be good to be able to specify the column position that will be returned to the GET.

Thanks

Joe

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCGETBROWSE

#4 Post by unixkd »

Hi Roger/All

DCGETBROWSE DATA aItemDesc GET oItem

Requires DCGETOPTIONS NOEDITNAVKEYS {||.f.} to work correctly but my clients are used to using ENTER key to move from a GET field to another and will not like to change it. Any workaround ?

Thanks

Joe

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCGETBROWSE

#5 Post by rdonnay »

How can I make the command below to have other parameter like:
I still don't understand what you are asking.

You showed that you know how to make a command with 3 parameters.

How are 6 parameters any different?
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCGETBROWSE

#6 Post by rdonnay »

Requires DCGETOPTIONS NOEDITNAVKEYS {||.f.} to work correctly
WHAT requires this to work correctly?

I don't understand what you are asking.

Start from the beginning and tell me what it is that you are trying to do?
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCGETBROWSE

#7 Post by unixkd »

OK.

The following code is sample from \EXP19\SAMPLE\GETBROWSE

1. Replace the DCGETOPTIONS of the Main() in this sample with DCGETOPTIONS TABSTOP NOSUPERVISE // NOEDITNAVKEYS {||.f.}
Note that I comment out // NOEDITNAVKEYS {||.f.}

2. Recompile and the run the sample.

3. In the first get enter A or B or any Letter. Then press 'DOWN arrow' continuously and notice the behavior of the browse.

4. If you un-comment the NOEDITNAVKEYS {||.f.} by adding it back to the DCGETOPTIONS the program works correctly BUT will not
allow you to use the ENTER key to move from GET cFileName1 to GET cFileName2



Code: Select all

 

/*
This example show how to connect a browse to a Get as a dropdown.



*/

#command DCGETBROWSE [DATA <d>] [GET <g>] => ;
  GetBrowse( <d>, @<g>, GetList )

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], GetOptions, oGet1, oGet2, oGet3, aDir1, aDir2, aDir3, ;
      i, cFileName1, cFileName2, cFileName3

aDir1 := Directory('..\..\data\*.*')

FOR i := 1 TO Len(aDir1)
  aDir1[i,1] := Upper(aDir1[i,1])
NEXT

aDir2 := AClone(aDir1)
aDir3 := AClone(aDir2)

cFileName1 := Space(20)
cFileName2 := Space(20)
cFileName3 := Space(20)

@ 0,0 DCSAY 'Enter File Name 1' GET cFileName1 ;
      PICTURE '@!' ;
      SAYSIZE 0 ;
      GETOBJECT oGet1 ;

DCGETBROWSE DATA aDir1 GET oGet1

@ 2,0 DCSAY 'Enter File Name 2' GET cFileName2 ;
      PICTURE '@!' ;
      SAYSIZE 0 ;
      GETOBJECT oGet2 ;

DCGETBROWSE DATA aDir2 GET oGet2

@ 4,0 DCSAY 'Enter File Name 3' GET cFileName3 ;
      PICTURE '@!' ;
      SAYSIZE 0 ;
      GETOBJECT oGet3 ;

DCGETBROWSE DATA aDir3 GET oGet3

DCGETOPTIONS  TABSTOP NOSUPERVISE  // NOEDITNAVKEYS {||.f.}

DCREAD GUI FIT TITLE 'Get with a Browse DropDown' ;
       OPTIONS GetOptions

RETURN nil

* -------------

FUNCTION GetBrowse( aData, oGet, GetList )

LOCAL nPointer, oBrowse, oStatic

@ DCGUI_ROW, DCGUI_COL DCPUSHBUTTON SIZE 20,20 PIXEL ;
      CAPTION 'u' FONT '12.Marlett' ;
      ACTION {||PostAppEvent(xbeP_Keyboard,xbeK_SH_DOWN,,oGet)} ;
      NOTABSTOP

@ 0,0 DCSTATIC OBJECT oStatic TYPE XBPSTATIC_TYPE_TEXT SIZE 10,10 ;
      INVISIBLE

@ 0,0 DCBROWSE oBrowse DATA aData ;
       PARENT oStatic ;
       NOTABSTOP ;
       SIZE 10,10 ;
       NOHSCROLL ;
       POINTER nPointer ;
       ITEMSELECTED {||oGet:setData(Pad(aData[nPointer,1],20)), ;
                     DC_GetRefresh(oGet), ;
                     oStatic:hide(), ;
                     SetAppFocus(oGet)} ;
       LOSTFOCUS {|a,b,o|o:hide()}

DCBROWSECOL ELEMENT 1 WIDTH 16 PARENT oBrowse

DCEVAL {||oStatic:setPos({oGet:currentPos()[1], ;
                          oGet:currentPos()[2]-oStatic:currentSize()[2]}), ;
          oStatic:setSize({oGet:currentSize()[1]+15,oStatic:currentSize()[2]}), ;
          oBrowse:setSize(oStatic:currentSize()), ;
          oGet:setInputFocus := {||oStatic:hide()}, ;
          oGet:keyboard := {|nKey,b,oGet|SeekFile(aData,nKey,oGet,oBrowse,oStatic)} }

RETURN nil

* -------------

PROC appsys ; return

* -------------

STATIC FUNCTION SeekFile( aDir, nKey, oGet, oBrowse, oStatic )

LOCAL nFound, cBuffer := Trim(oGet:get:buffer)

IF nKey == xbeK_BS .OR. nKey == xbeK_DEL .OR. nKey == xbeK_TAB
  RETURN nil
ELSEIF nKey == xbeK_SH_DOWN
  oStatic:show()
  oStatic:toFront()
  oBrowse:show()
  oBrowse:forceStable()
  oBrowse:refreshAll()
  SetAppFocus(oBrowse)
  RETURN nil
ELSEIF nKey == xbeK_DOWN .AND. oStatic:isVisible()
  SetAppFocus(oBrowse)
  RETURN nil
ENDIF

IF nKey == xbeK_ENTER
  IF oStatic:isVisible()
    PostAppEvent(xbeBRW_ItemSelected,,,oBrowse)
  ENDIF
  RETURN nil
ENDIF

IF !Empty(cBuffer)
  nFound := AScan(aDir,{|a|a[1]=cBuffer})
  IF nFound > 0
    oBrowse:arrayElement := nFound
    oBrowse:refreshAll()
    oStatic:show()
    oStatic:toFront()
    oBrowse:show()
  ENDIF
ELSE
  oStatic:hide()
ENDIF

RETURN nil




User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: DCGETBROWSE

#8 Post by Auge_Ohr »

hi

as i understand you want a different Way to navigate when your Customer press ENTER.

you have something like this

Code: Select all

   oGet:keyboard := {|nKey,b,oGet|SeekFile(aData,nKey,oGet,oBrowse,oStatic)} }

STATIC FUNCTION SeekFile( aDir, nKey, oGet, oBrowse, oStatic )
...
IF nKey == xbeK_BS .OR. nKey == xbeK_DEL .OR. nKey == xbeK_TAB
...
ELSEIF nKey == xbeK_SH_DOWN
...
ELSEIF nKey == xbeK_DOWN .AND. oStatic:isVisible()
...
ENDIF
// put this as first !
IF nKey == xbeK_ENTER
while you want to change ENTER put these line first

Code: Select all

IF nKey == xbeK_ENTER
   IF iEdit = .T.  // allow Edit
      PostAppEvent(xbeBRW_ItemSelected,,,oBrowse)
   ELSE
      PostAppEvent(xbeK_DOWN,,,oBrowse)
   ENDIF
ENDIF

DO CASE
   CASE nKey == xbeK_BS .OR. nKey == xbeK_DEL .OR. nKey == xbeK_TAB
...
when lEdit = .F. and press ENTER than Cursor move DOWN in Browse.
is this what you want :?:
greetings by OHR
Jimmy

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCGETBROWSE

#9 Post by unixkd »

Hi Jimmy

I dont understand your solution.

Pls insert the codes required in the seekfile function for me to run directly.

Thanks.

Joe

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: DCGETBROWSE

#10 Post by Auge_Ohr »

hi,

you want to change behavior of ENTER and you have a o:Keyboard Slot.
so make Change in o:Keyboard and not in Express++ CLASS.
greetings by OHR
Jimmy

Post Reply