Page 1 of 1

a few questions about browse

Posted: Tue Dec 20, 2016 9:37 pm
by plantenkennis
Hello Antonio,
I have two question about browse:

1.
Is it possible to get the column number where I click in. I want to have a browse for an array, where in the first column there is a value and in the second column i have a bmp to delete that row.

Code: Select all

AADD(aName, { 'first name', 'delete.bmp'})
AADD(aName, { 'second name', 'delete.bmp'})
AADD(aName, { 'third name', 'delete.bmp'})
AADD(aName, { 'fourth name', 'delete.bmp'})

        @ 270, 120 LISTBOX oBrwNed FIELDS "", "" ;
            HEADERS "Value", "Delete" ;
            OF oFld:aDialogs[ 1 ] SIZE 450, 150
            oBrwNed:SetArray( aName )
            oBrwNed:bLine = { | nRow | IF( nRow <= Len( aName ), aName[ nRow ], { "", "" } ) }
            oBrwNed:SetColWidth( 1, 400 )
            oBrwNed:SetColWidth( 2, 30 )
            oBrwNed:SetColBmp( 2 )
            oBrwNed:SetColEditable( 1, .F. )
            oBrwNed:SetColEditable( 2, .F. )
            oBrwNed:SetColor( OwnClrGreen, OwnClrYellow )
            oBrwNed:Select( 1 )
            oBrwNed:bChange := { | obj , nindex| Msginfo( obj:nRowPos() )}
            oBrwNed:bAction := { | obj , nindex|  RK_Wijzig(oBrwNed:nArrayAt, 'Name', aName) }
 
If I click on a row I can change the name, but if I click on the Delete button on column 2 I want to delete it. Is this possible?

2.
When I click in the same browse on an empty row I still get value 1 as nRowPos. Should this not be 0 (zero) or NILL

Re: a few questions about browse

Posted: Wed Dec 21, 2016 7:23 am
by Antonio Linares
René,

This may help:

http://stackoverflow.com/questions/1856 ... and-column

I am reviewing it

Re: a few questions about browse

Posted: Wed Dec 21, 2016 7:25 am
by Antonio Linares

Re: a few questions about browse

Posted: Wed Dec 21, 2016 8:33 am
by Antonio Linares
René,

Already implemented, I am emailing you the modified libs.

Here it is an example of use:

oBrw:bAction = { | oBrw | MsgInfo( oBrw:nColPos() ) }

I am going to review the nRowPos issue

Re: a few questions about browse

Posted: Wed Dec 21, 2016 8:45 am
by Antonio Linares
> I am going to review the nRowPos issue

Fixed. I am sending you new modified libs.

Now nRowPos() should return zero when clicking on an empty row

I have not tested it. I appreciate your feedback

Re: a few questions about browse

Posted: Wed Dec 21, 2016 7:16 pm
by plantenkennis
Hello Antonio,

Wow, every time I am surprised by the speed you addept the libs. Both functions are working great. I am very happy with this.

Re: a few questions about browse

Posted: Wed Dec 21, 2016 7:21 pm
by Antonio Linares
very good :-)

Re: a few questions about browse

Posted: Fri Dec 30, 2016 5:29 pm
by plantenkennis
Hello Antonio,

I need a little more help with my browse. I have a browse with an array. In column one I have a name, in column two I have a bitmap to delete that name. With the oBrw:oChange I can get the column where there is clicked, but only if the row is also changed. If the row is selected and I click on the delete bitmap, nothing happens. Here is my code.

Code: Select all

#include "FiveMac.ch"

function Main()

   local oWnd, oBrw
   local cpath:=Path()
   local aNames[0][2]
   
    AADD(aNames, {'name 1', 'Delete.png'})
    AADD(aNames, {'name 2', 'Delete.png'})
    AADD(aNames, {'name 3', 'Delete.png'})
    AADD(aNames, {'name 4', 'Delete.png'})
    AADD(aNames, {'name 5', 'Delete.png'})

   DEFINE WINDOW oWnd TITLE "DBF Browse" ;
      FROM 213, 109 TO 650, 820

  @ 48, 20 LISTBOX oBrw FIELDS "", "" ;
            HEADERS "name", "Del" ;
            OF oWnd SIZE 450, 150
            oBrw:SetArray( aNames )
            oBrw:bLine = { | nRow | IF( nRow <= Len( aNames ), aNames[ nRow ], { "", "" } ) }
            oBrw:SetColWidth( 1, 300 )
            oBrw:SetColWidth( 2, 50 )
            oBrw:SetColEditable( 1, .F. )
            oBrw:SetColEditable( 2, .F. )
            oBrw:SetColBmp( 2 )
            oBrw:Select( 1 )
            oBrw:bChange := { | oBrw | Msginfo('column: ' + STR(oBrw:nColPos()) )}
            oBrw:bAction := { | obj , nindex | MsgInfo( obj:nRowPos() ) }
   

   ACTIVATE WINDOW oWnd

return nil
 
This is what I want:
If the user doubleclicks on an item in the first column, he can change this item
If the user clicks on the delete-button in the second column, the user gets the question if he wants to delete that row.
Am I missing something, or is this not possible.

Re: a few questions about browse

Posted: Fri Dec 30, 2016 6:08 pm
by Antonio Linares
René,

Try this:

oBrw:bAction := { | obj | If( oBrw:nColPos() == 2, MsgInfo( "delete" ),) }

There is no need to use bChange

Re: a few questions about browse

Posted: Fri Dec 30, 2016 7:13 pm
by plantenkennis
Hello Antonio,

But the bAction only reacts on a doubleclick, and I want the delete action just when I click on it.

Re: a few questions about browse

Posted: Fri Dec 30, 2016 8:18 pm
by Antonio Linares
René,

I have modified FiveMac libs and already sent them to you

This is the way to do it:

oBrw:bMouseDown = { | nRow, nCol, oControl | MsgInfo( Str( nCol ) ) }

Please try it and let me know if it is ok for you, thanks

Re: a few questions about browse

Posted: Sat Dec 31, 2016 9:48 am
by plantenkennis
Hello Antonio,

Again, thank you very much. This is excactly what I mean.

HAPPY NEWYEAR :D

Re: a few questions about browse

Posted: Sat Dec 31, 2016 9:56 am
by Antonio Linares
Happy new year :-)