BUG: XBROWSE editstyle EDIT_GET_LISTBOX

BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Fri Apr 05, 2013 11:16 am

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
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Fri Apr 05, 2013 2:49 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Fri Apr 05, 2013 3:00 pm

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
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Sun Apr 07, 2013 1:31 pm

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
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Sun Apr 14, 2013 7:04 pm

Antonio, please look also on this last two Points!
Many thanks!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Mon Apr 15, 2013 6:05 am

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. )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Mon Apr 15, 2013 6:17 am

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. ) ),) }
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Mon Apr 15, 2013 9:46 am

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. )
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Mon Apr 15, 2013 10:07 am

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 :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Mon Apr 15, 2013 11:45 am

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
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Mon Apr 15, 2013 12:55 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Mon Apr 15, 2013 1:09 pm

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!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Mon Apr 15, 2013 1:58 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby byte-one » Mon Apr 15, 2013 3:41 pm

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?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: XBROWSE editstyle EDIT_GET_LISTBOX

Postby Antonio Linares » Mon Apr 15, 2013 6:20 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 131 guests

cron