Page 1 of 2

BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Fri Apr 05, 2013 11:16 am
by byte-one
On this type of editstyle we can input a free text in this col, but when i open and then only close the Combobox without select any item, this text are instantly overwritten with the first item from the list.
Another error when i Input TAB on the open listbox:
Error BASE/1005 Class: 'NIL' has no property: NLASTKEY
Args:
[ 1] = U
[ 2] = N 13

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Fri Apr 05, 2013 2:49 pm
by Antonio Linares
Günther,

I have fixed it this way. Search for LISTBOX inside xbrowse.prg and change this:
Code: Select all  Expand view
  @ 0, 0 LISTBOX ::oEditLbx VAR nAt OF ::oBrw SIZE 0,0 ITEMS ::aEditListTxt ;
         COLOR aColors[ 1 ], aColors[ 2 ] FONT oFont

   ::oEditLbx:bLostFocus := { | oLbx, hWndFocus | ::PostEdit( aBound[ Max( 1, nAt ) ] ) }

   ::oEditLbx:bLButtonUp := {|| ::oEditLbx:Change(),;
                                If( ::oEditLbx != nil, ::oEditLbx:nLastKey := VK_RETURN,),;
                                ::PostEdit( aBound[ nAt ], .t. ) }

   ::oEditLbx:bChange = {|| If( ::oEditLbx != nil, ::oEditLbx:nLastKey := VK_RETURN,) }

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

also here:
Code: Select all  Expand view
     case ::nEditType == EDIT_LISTBOX
         if xValue != nil
            if ::bEditWhen == nil .or. Eval( ::bEditWhen, Self ) .and. ::oEditLbx:nLastKey == VK_RETURN
               Eval( ::bOnPostEdit, Self, xValue, If( ::oEditLbx != nil, ::oEditLbx:nLastKey, 0 ) )
            endif
 

with those changes this example seems to be working fine:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oBrw, aValues := { Array( 2 ) }

   DEFINE DIALOG oDlg SIZE 500, 300
   
   @ 0, 0 XBROWSE oBrw OF oDlg ;
      FIELDS aValues[ oBrw:nArrayAt ][ 1 ], aValues[ oBrw:nArrayAt ][ 2 ] ;
      COLSIZES 220, 220 ;
      HEADERS "One", "Two"

   oBrw:SetArray( aValues )
   oBrw:aCols[ 1 ]:nEditType    = EDIT_GET_LISTBOX
   oBrw:aCols[ 1 ]:aEditListTxt = { "111111", "22222" }
   oBrw:aCols[ 1 ]:bOnPostEdit  = { | o, v | MsgInfo( v ) }
   oBrw:CreateFromCode()

   oDlg:oClient = oBrw

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT oDlg:ReSize()

return nil

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Fri Apr 05, 2013 3:00 pm
by Antonio Linares
This seems a better implementation, as now we can use Enter to select an item:

Code: Select all  Expand view
  @ 0, 0 LISTBOX ::oEditLbx VAR nAt OF ::oBrw SIZE 0,0 ITEMS ::aEditListTxt ;
         COLOR aColors[ 1 ], aColors[ 2 ] FONT oFont

   ::oEditLbx:bLostFocus := { | oLbx, hWndFocus | ::PostEdit( aBound[ Max( 1, nAt ) ] ) }

   ::oEditLbx:bLButtonUp := {|| ::oEditLbx:Change(),;
                                ::PostEdit( aBound[ nAt ], .t. ) }

   ::oEditLbx:bChange = {|| If( ::oEditLbx != nil, ::oEditLbx:nLastKey := VK_RETURN,) }

   IF ::oBrw:oWnd:IsKindOf( "TDIALOG" )
      ::oEditLbx:nDlgCode = DLGC_WANTALLKEYS
      ::oEditLbx:bKeyDown   := { | nKey | If( nKey == VK_RETURN,;
                                            ( ::oEditLbx:Change(),;
                                              ::PostEdit( aBound[ nAt ], .t. ) ),) }

   ELSE
 

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Sun Apr 07, 2013 1:31 pm
by byte-one
Antonio, editing now is OK! Thanks.

But two points are also to do:
1.) If the listbox are on bottom half in the xbrowse not the full list are shown on opening. The list is clipped in some cases!

2.) When i Input TAB on the opened listbox:
Error BASE/1005 Class: 'NIL' has no exported method: CHANGE
Args:
[ 1] = U

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Sun Apr 14, 2013 7:04 pm
by byte-one
Antonio, please look also on this last two Points!
Many thanks!

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 6:05 am
by Antonio Linares
Günther,

Please go to line 11135 in xbrowse.prg and change this:

::oEditLbx:Move( nRow, nCol, nWidth, nHeight, .t. )

to

nRow = If( nRow + nHeight > ::nHeight, ::nHeight - nHeight, nRow )
::oEditLbx:Move( nRow, nCol, nWidth, nHeight, .t. )

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 6:17 am
by Antonio Linares
For the Tab error please modify this in line 11125:

Code: Select all  Expand view
     ::oEditLbx:bKeyDown   := { | nKey | If( nKey == VK_RETURN,;
                                            ( If( ::oEditLbx != nil, ::oEditLbx:Change(),),;
                                              ::PostEdit( aBound[ nAt ], .t. ) ),) }
 

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 9:46 am
by byte-one
Antonio, this has no effect. Also your line-numbers are not from 13.3 ??

Please go to line 11135 in xbrowse.prg and change this:

::oEditLbx:Move( nRow, nCol, nWidth, nHeight, .t. )

to

nRow = If( nRow + nHeight > ::nHeight, ::nHeight - nHeight, nRow )
::oEditLbx:Move( nRow, nCol, nWidth, nHeight, .t. )

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 10:07 am
by Antonio Linares
Günther,

Look for ::oEditLbx:Move in xbrowse.prg, there is only one occurrence and change it there as explained.

I have not tested it myself, but I think it should work :-)

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 11:45 am
by byte-one
Antonio, not the right effect! Only the last visible row claps the listbox to top. All other rows claps the listbox down with vertical scroll and would be pressed and pressed. In my opinion the following code is the point to Show!
Code: Select all  Expand view
  If nRow + nHeight > ::oBrw:BrwHeight()
      If (::oBrw:BrwHeight() - nRow) < ::oBrw:nRowHeight
         do while ( nRow -  nHeight - ::oBrw:nRowHeight + 1 ) < 0
            nHeight -= FontHeight( ::oBrw, ::oBrw:oFont )
         enddo
         nRow :=  nRow - nHeight - ::oBrw:nRowHeight + 1
      else
         nHeight := ::oBrw:BrwHeight() - nRow
      Endif
   Endif

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 12:55 pm
by Antonio Linares
Günther,

If you try this example, with my changes, it shows fine:

gunther4.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oBrw, aValues := { Array( 2 ) }, n
   
   for n = 1 to 50
      AAdd( aValues, ATail( aValues ) )
   next  

   DEFINE DIALOG oDlg SIZE 500, 300
   
   @ 0, 0 XBROWSE oBrw OF oDlg ;
      FIELDS aValues[ oBrw:nArrayAt ][ 1 ], aValues[ oBrw:nArrayAt ][ 2 ] ;
      COLSIZES 220, 220 ;
      HEADERS "One", "Two"

   oBrw:SetArray( aValues )
   oBrw:aCols[ 1 ]:nEditType    = EDIT_GET_LISTBOX
   oBrw:aCols[ 1 ]:aEditListTxt = { "111111", "22222" }
   oBrw:aCols[ 1 ]:bOnPostEdit  = { | o, v | MsgInfo( v ) }
   oBrw:CreateFromCode()

   oDlg:oClient = oBrw

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT oDlg:ReSize()

return nil


Image

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 1:09 pm
by byte-one
Antonio, please use a list with more (10 or so) items and test it not on the last visible row but one or two rows above!

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 1:58 pm
by Antonio Linares
Günther,

This seems to be a better fix:

nRow = If( nRow + nHeight > ::oBrw:nHeight, nRow - nHeight - ::oBrw:nRowHeight, nRow )

Still we should be able to avoid the bottom scrollbar too, thats pending

and yes, that section of code that you mentioned, does not seem to be needed anymore, thanks

Image

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 3:41 pm
by byte-one
Antonio it works! If also the vscroll are functioning, this is a perfect thing. Is it possibility, the listbox drawing over the size from the browse as it is also on normal dialogs?

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

PostPosted: Mon Apr 15, 2013 6:20 pm
by Antonio Linares
Günther,

Do you mean that the listbox is out of the browse area ?

Rao has implemented a better version that takes some more details into account for a better positioning of the listbox