FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour xbrowse + EDIT_LISTBOX
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
xbrowse + EDIT_LISTBOX
Posted: Thu Jul 15, 2010 04:12 AM
Hola a todos,
Tengo un xbrowse en un DIALOG y en una columna con EDIT_LISTBOX, el caso es que en edicion en vez de seguir a la columna siguiente, pasa al siguiente control, en WINDOW anda ok, el problema lo presenta en dialogos

Aqui el code :

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local aData := {}
   local oWnd, oBrw, oBar

   define window oWnd

   define buttonbar oBar size 100,32 of oWnd 2007
   define button of oBar prompt 'AddRow' action AddRow( oBrw )
   define button of oBar prompt 'DeleteRow' action DelRow( oBrw )

   @ 0,0 xbrowse oBrw of oWnd ;
      header 'one','two','tipo', "cuatro" ;
      columns 1, 2, 3, 4 ;
      colsizes 50,70,50,70 ;
      pictures '999','mmm dd, yyyy', "9999.99" ;
      array aData lines cell fastedit footers

   WITH OBJECT oBrw
      :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
      :bPastEof  := { || AddRow( oBrw ) }
      :bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }
   END

   AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )

   WITH OBJECT oBrw:tipo
      :nEditType        := EDIT_LISTBOX
      :aEditListBound   := ;
      :aEditListTxt     := { "NOV", "NTO", "TOR", "VAC", "VAQ", "TM ", "TH " }
   END
   WITH OBJECT oBrw:cuatro
      :nTotal        := 0
      :lTotal        := .t.
   END

   WITH OBJECT oBrw
      :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
      :bPastEof  := { || AddRow( oBrw ) }
      :bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }
      :MakeTotals()
   END

   oBrw:CreateFromCode()
   oWnd:oClient := oBrw
   activate window oWnd

return nil

static function AddRow( oBrw )

   static n := 0

   AAdd( oBrw:aArrayData, { n, date()+n, "NOV", 0 } )
   n++
   oBrw:GoBottom()
   oBrw:Refresh()
   oBrw:SetFocus()

return nil

static function DelRow( oBrw )

   if oBrw:nLen > 0
      ADel( oBrw:aArrayData, oBrw:nArrayAt )
      ASize( oBrw:aArrayData, oBrw:nLen - 1 )
      oBrw:Refresh()
   endif
   oBrw:SetFocus()

return nil


si alguien lo pudo resolver agradeceria comparta la solucion.

Gracias.
Salu2, Ariel.
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: xbrowse + EDIT_LISTBOX
Posted: Thu Jul 15, 2010 01:15 PM
Ariel.

Ejemplo usando DIALOG
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local aData := {}
   local oWnd, oBrw, oBar

   define dialog oWnd size 300, 300

   @ 0,0 xbrowse oBrw of oWnd ;
      header 'one','two','tipo', "cuatro" ;
      columns 1, 2, 3, 4 ;
      colsizes 50,70,50,70 ;
      pictures '999','mmm dd, yyyy', "9999.99" ;
      array aData lines cell fastedit footers

   WITH OBJECT oBrw
      :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
      :bPastEof  := { || AddRow( oBrw ) }
      :bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }
   END

   AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )

   WITH OBJECT oBrw:tipo
      :nEditType        := EDIT_LISTBOX
      :aEditListBound   := ;
      :aEditListTxt     := { "NOV", "NTO", "TOR", "VAC", "VAQ", "TM ", "TH " }
   END
   WITH OBJECT oBrw:cuatro
      :nTotal        := 0
      :lTotal        := .t.
   END

   WITH OBJECT oBrw
      :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
      :bPastEof  := { || AddRow( oBrw ) }
      :bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }
      :MakeTotals()
   END

   oBrw:CreateFromCode()
   oWnd:oClient := oBrw
   activate dialog oWnd on init ( MakeBar( oWnd, oBrw ), oWnd:Resize() )

return nil

static function AddRow( oBrw )

   static n := 0

   AAdd( oBrw:aArrayData, { n, date()+n, "NOV", 0 } )
   n++
   oBrw:GoBottom()
   oBrw:Refresh()
   oBrw:SetFocus()

return nil

static function DelRow( oBrw )

   if oBrw:nLen > 0
      ADel( oBrw:aArrayData, oBrw:nArrayAt )
      ASize( oBrw:aArrayData, oBrw:nLen - 1 )
      oBrw:Refresh()
   endif
   oBrw:SetFocus()

return nil


function MakeBar( oWnd, oBrw )
   
   local oBar

   define buttonbar oBar size 100,32 of oWnd 2007
   define button of oBar prompt 'AddRow' action AddRow( oBrw )
   define button of oBar prompt 'DeleteRow' action DelRow( oBrw )

return oBar
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: xbrowse + EDIT_LISTBOX
Posted: Mon Jul 26, 2010 01:53 PM
Hola a Todos,
pos, sigo con el mismo error, pero detectando algunas cosas mas, si el xbrowse esta en un DIALOG, y ademas del xbrowse hay por ejemplo un boton, ahi se produce el error que luego del edit_listbox, en vez de pasar a la proxima columna del xbrowse, el focus salta al proximo control del dialog.

Aqui dejo el codigo que reproduce el error :

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local aData := {}
   local oWnd, oBrw, oBar

   define dialog oWnd size 600, 300

   @ 10,0 xbrowse oBrw of oWnd ;
      header 'one','two','tipo', "cuatro" ;
      columns 1, 2, 3, 4 ;
      colsizes 50,70,50,70 ;
      pictures '999','mmm dd, yyyy', "9999.99" ;
      SIZE 300, 300 PIXEL ;
      array aData lines cell fastedit footers

   WITH OBJECT oBrw
      :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
      :bPastEof  := { || AddRow( oBrw ) }
      :bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }
   END

   AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )

   WITH OBJECT oBrw:tipo
      :nEditType        := EDIT_LISTBOX
      :aEditListBound   := ;
      :aEditListTxt     := { "NOV", "NTO", "TOR", "VAC", "VAQ", "TM ", "TH " }
   END
   WITH OBJECT oBrw:cuatro
      :nTotal        := 0
      :lTotal        := .t.
   END

   WITH OBJECT oBrw
      :bClrStd    := { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 224, 236, 255 ) }, ;
                         { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
      :bPastEof  := { || AddRow( oBrw ) }
      :bKeyDown := {| nKey | If( nKey == VK_DELETE, DelRow( oBrw ), ) }
      :MakeTotals()
   END

   oBrw:CreateFromCode()
//   oWnd:oClient := oBrw

   @ 60,10 BUTTONBMP PROMPT "OK" OF oWnd ACTION oWnd:End() SIZE 120, 20 PIXEL

   activate dialog oWnd on init ( MakeBar( oWnd, oBrw ), oWnd:Resize() )

return nil

static function AddRow( oBrw )

   static n := 0

   AAdd( oBrw:aArrayData, { n, date()+n, "NOV", 0 } )
   n++
   oBrw:GoBottom()
   oBrw:Refresh()
   oBrw:SetFocus()

return nil

static function DelRow( oBrw )

   if oBrw:nLen > 0
      ADel( oBrw:aArrayData, oBrw:nArrayAt )
      ASize( oBrw:aArrayData, oBrw:nLen - 1 )
      oBrw:Refresh()
   endif
   oBrw:SetFocus()

return nil


function MakeBar( oWnd, oBrw )
   
   local oBar

   define buttonbar oBar size 100,32 of oWnd 2007
   define button of oBar prompt 'AddRow' action AddRow( oBrw )
   define button of oBar prompt 'DeleteRow' action DelRow( oBrw )

return oBar


alguna ayuda, please.
Gracias
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: xbrowse + EDIT_LISTBOX
Posted: Thu Jul 29, 2010 04:25 PM

Ariel

Este cambio es necesario en:

METHOD ShowBtnList( nKey ) CLASS TXBrwColumn

IF ::oBrw:oWnd:IsKindOf( "TDIALOG" )
::oEditLbx:nDlgCode = DLGC_WANTALLKEYS
::oEditLbx:bKeyDown := {|k| ::oEditLbx:nLastKey := k, nil }

ELSE
::oEditLbx:bKeyDown := {|k| ::oEditLbx:nLastKey := k, ;
If( k == VK_RETURN .and. nAt > 0, xValue := aBound[ nAt ], ),;
If( k == VK_RETURN .or. k == VK_ESCAPE, ::PostEdit( xValue, .t. ), ) }
ENDIF

Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: xbrowse + EDIT_LISTBOX
Posted: Thu Jul 29, 2010 11:13 PM

Daniel,

Gracias por responder, pero el problema persiste, ahora si tu tienes, basado en el mismo ejemplo un boton mas, el foco se va a ese boton fuera del xbrowse, o sea en vez de seguuir en la siguiente columna, pasa el foco al 2do boton.

Seguimos esperando...

Salu2, Ariel.

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: xbrowse + EDIT_LISTBOX
Posted: Fri Jul 30, 2010 01:22 PM
Ariel


este cambio es requerido en el

subtituye este CASE en METHOD KeyChar( nKey, nFlags ) CLASS TXBrowse
Code (fw): Select all Collapse
      case nKey == VK_RETURN
         oCol := ::SelectedCol()
         if oCol:oEditGet != nil
            PostMessage( oCol:oEditGet:hWnd, WM_KEYDOWN, nKey )   //VK_RETURN )
         elseif oCol:lEditable .and. ! oCol:hChecked .and. ::lEnterKey2Edit .and. ! ( oCol:nEditType == EDIT_LISTBOX .or. oCol:nEditType == EDIT_GET_LISTBOX )
            return oCol:Edit()
         elseif oCol:nEditType != EDIT_LISTBOX .or. oCol:nEditType != EDIT_GET_LISTBOX
            //Simulate Click over button for no lost focus
            PostMessage( oCol:oBtnList:hWnd, WM_LBUTTONDOWN, 1, 1 )   
            PostMessage( oCol:oBtnList:hWnd, WM_LBUTTONUP, 1, 1 )  
         elseif ::oTreeItem!=nil
            If( ::oTreeItem:oTree != nil,( ::oTreeItem:Toggle(), ::Refresh() ),)
         else
            ::GoRight()
         endif

Continue the discussion