[xBrowse] - Implementing picklist

[xBrowse] - Implementing picklist

Postby hua » Fri Dec 04, 2009 2:21 am

Basically what I want to do is bypass the validation done in current column and set focus to the next column.

It'd be easier to understand using a self-contained example that I'm attaching below.

Here's the steps to show you what I mean:

1. Set focus in column Account and press F2. A dialogue-box box simulating a picklist appear, press Yes (this represent user selecting an account code).
2. Now a validation is done and it's determined this particular account code requires getting additional info. Press Yes at the More-Info dialogue box that appear
3. At this point, the focus is back at column Account. I really wanted it to be in the next column if user did key in additional info at step 2 but I don't know how to programmatically do so.
4. Since now user is at column Account, they'd have no choice but press the right arrow key to go to the next column but this would cause the More-Info dialogue box to pops-up again which is really annoying.

Anyone has any idea how to smooth all of these out?

Prg
Code: Select all  Expand view

/**************
  Author: Hua
  Description: Sample showing how user can invoke a picklist using F2 and
               stuff selected value back in the xBrowse's cell

****/

#include "FiveWin.ch"
#include "xbrowse.ch"

static oWnd, aFiledbf

#define LN_ACCN   1
#define LN_CENTRE 3
#define LN_ADDITIONAL 5

function Main()

  local oDlg, oBrw
  aFiledbf := { {space(5), space(20), space(3), 0.00,""}, ;
                {space(5), space(20), space(3), 0.00,""}  ;
              }

  define window oWnd
  define dialog oDlg resource "journal" of oWnd

  // bof - xBrowse parameters
  redefine xbrowse oBrw id 101 of oDlg                   ;
    columns 1, 2, 3, 4                                   ;
    headers "Account", "Description", "Centre", "Amount" ;
    pictures "@!",,"@!","999,999.99"                     ;
    array aFiledbf                                       ;
    footers fastedit lines cell update ;

  oBrw:bKeyDown := {| nKey | if(nKey==VK_F2, CallColPick(oBrw), nil) }
  aeval(oBrw:aCols,{|o| o:lAutoSave := .t., o:nEditType := EDIT_GET})

  with object oBrw:aCols[LN_ACCN]
    :nEditType := EDIT_GET_BUTTON
    :addResource( "down" )
    :nBtnBmp := 1
    :bEditBlock := {|row, col, oCol| picklist("Account", oBrw, LN_ACCN) }
    :bEditValid := {|oGet, oCol| ChkAccn(oGet, oCol, oBrw)}
  end


  with object oBrw:aCols[LN_CENTRE]
    :nEditType := EDIT_GET_BUTTON
    :addResource( "down" )
    :nBtnBmp := 1
    :bEditBlock := {|row, col, oCol| picklist("Centre", oBrw, LN_CENTRE) }
    :bEditValid := {|oGet, oCol| IsValidCentre(oGet) }
  end

  // eof - xBrowse parameters

  activate dialog oDlg              ;
    on init oDlg:oClient := oBrw    ;
    nomodal valid (oWnd:end(), .t.)

  activate window oWnd on init (oWnd:resize(), oWnd:center(), oBrw:setFocus()) //maximized

return nil
//----------------------------------------------------------------------
function picklist(cTitle, oBrw, ele)
  local oCol := oBrw:SelectedCol()
  local xRet // will hold the value selected by user if any
  local lSelect := msgyesno("Imagine this is a picklist where user selects" + CRLF +;
                            cTitle + " code. Proceed as though user make selection?", "Pick your "+cTitle+" code" )

  if lSelect
     xRet := upper(cTitle) + "1" // hardcoding the return value for illustrations sake

     // if user wasn't editing, have to manually stuff the value in
     if oCol:oEditGet == nil
        oBrw:aArrayData[oBrw:nArrayAt, ele] := xRet
        oBrw:drawSelect()
        oCol:edit()
        oCol:oEditGet:PostMsg(WM_KEYDOWN, VK_RETURN)
     else
        oCol:oEditGet:varPut(xRet)
        oCol:oEditGet:PostMsg(WM_KEYDOWN, VK_RETURN)
        lRefocus := .f.
     endif
  endif
return xRet
//----------------------------------------------------------------------
function CallColPick(oBrw)
  // will be called when user presses F2. If we're at column where picklist is available
  // eval its bEditBlock which in turn should be calling picklist()
  local oCol := oBrw:SelectedCol()

  // if we're in correct column, invoke picklist
  if oCol:cHeader == "Account" .or. oCol:cHeader == "Centre"
     oCol:oBtnElip:PostMsg(FM_CLICK)
  endif
return nil
//----------------------------------------------------------------------
function ChkAccn(oGet, oCol, oBrw)
  local cTAccn := oGet:value(), lRet := .t.
  if trim(cTAccn) == "ACCOUNT1" // we need more info if it's this account
     lRet := msgyesno("Needs more info for 'ACCOUNT1'." +CRLF + ;
                      "Simulate popup appearing and user keyed-in the additional info?","Get more info")
     if lRet
        oBrw:aArrayData[oBrw:nArrayAt, LN_ADDITIONAL] := 'bla bla'
     endif
  endif
  oBrw:setFocus()
return lRet
//----------------------------------------------------------------------
function IsValidCentre(oGet)
  local cCentre := oGet:value(), lRet := .t.

  // profit centre validation goes here
return lRet
 


RC
Code: Select all  Expand view

down BITMAP LOADONCALL MOVEABLE DISCARDABLE
{
 '42 4D 06 01 00 00 00 00 00 00 76 00 00 00 28 00'
 '00 00 10 00 00 00 12 00 00 00 01 00 04 00 00 00'
 '00 00 90 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
 '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
 '00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF'
 '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
 '00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88'
 '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
 '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
 '00 00 00 08 88 88 88 88 88 88 88 88 88 88 88 88'
 '88 80 88 88 88 88 88 88 88 00 08 88 88 88 88 88'
 '80 00 00 88 88 88 88 88 00 00 00 08 88 88 88 88'
 '88 00 08 88 88 88 88 88 88 00 08 88 88 88 88 88'
 '88 00 08 88 88 88 88 88 88 88 88 88 88 88 88 88'
 '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
 '88 88 88 88 88 88'
}

journal DIALOG 0, 0, 250, 115
STYLE DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN
CAPTION ""
FONT 10, "System"
{
 CONTROL "", 101, "TXBrowse", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 8, 4, 236, 104
}
 
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1040
Joined: Fri Oct 28, 2005 2:27 am

Re: [xBrowse] - Implementing picklist

Postby nageswaragunupudi » Fri Dec 04, 2009 3:21 am

Does it work if you call oBrw:GoRight() ?
Regards

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

Re: [xBrowse] - Implementing picklist

Postby hua » Fri Dec 04, 2009 4:22 am

I did give that a try but it will still invoke :bEditValid
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1040
Joined: Fri Oct 28, 2005 2:27 am

Re: [xBrowse] - Implementing picklist

Postby nageswaragunupudi » Fri Dec 04, 2009 4:26 am

bEditValid will be invoked. You need to code bEditValid codeblock to be aware of what you need to do.
Regards

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

Re: [xBrowse] - Implementing picklist

Postby hua » Fri Dec 04, 2009 4:32 am

Ok, thanks Rao. I'll sleep on it for a while
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1040
Joined: Fri Oct 28, 2005 2:27 am

Re: [xBrowse] - Implementing picklist

Postby James Bott » Fri Dec 04, 2009 5:29 pm

Hua,

Try something like:

Code: Select all  Expand view
:bEditValid := {|oGet, oCol| if(ChkAccn(oGet, oCol, oBrw), (oBrw:goRight(),.t.),.f.) }


James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: [xBrowse] - Implementing picklist

Postby hua » Mon Dec 07, 2009 3:03 am

Thanks for the reply James but my problem was my 'More-Info' dialogue box got executed twice because I placed it in :bEditValid.

Nevertheless, this is what I've done to solve it:
Code: Select all  Expand view

function main()
   .
   oBrw:aCols[LN_ACCN]:bEditWhen := {|oCol| lValidated := .f., .t.}
   oBrw:aCols[LN_ACCN]:bEditValid  := {|oGet, oCol| ChkAccn(oGet, oCol, oBrw, @lValidated)}
   .
return nil
//------------------------------------------------------------------------------------------------------------
function ChkAccn(oGet, oCol, oBrw, lValidated)
  local cTAccn := oGet:value(), lRet := .t.
  if lValidated
     return .t.
  endif
  .
  .
  if lRet
     lValidated := .t.
     oBrw:GoRight()
  endif
return lRet
 
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1040
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 12 guests