TCBrowse: clicking on headers

TCBrowse: clicking on headers

Postby Enrico Maria Giordano » Fri Jan 20, 2006 6:56 pm

In the following sample nothing happens when the headers are clicked. Why? How can I trap this event?

Code: Select all  Expand view  RUN
#include "Fivewin.ch"
#include "Tcbrowse.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw, oCol

    USE TEST

    DEFINE DIALOG oDlg SIZE 300, 300

    @ 0, 0 BROWSE oBrw

    ADD COLUMN TO oBrw;
               DATA TEST -> last;
               HEADER "LAST";
               COLOR CLR_RED, CLR_GREEN

    ADD COLUMN TO oBrw;
               DATA TEST -> first;
               HEADER "FIRST";
               COLOR CLR_RED, CLR_GREEN

    oBrw:lCellStyle = .T.

    oBrw:aActions = { { || MsgInfo( "Hello!" ) }, { || MsgInfo( "Hello!" ) } }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    CLOSE

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Fri Jan 20, 2006 8:34 pm

As I expect you know, TCBrowse is a subclass of TWBrowse. aAction is eval'd in method lButtonDown in TWBrowse. In TCBrowse, the method has been completely rewritten and aAction is not used anywhere in the method. So, it looks like it will require a significant rewrite of this method to get actions working.

You might consider using TSBrowse instead. I does everything TCBrowse does and a lot more including header actions. You can get a copy at my website.

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

Postby Enrico Maria Giordano » Fri Jan 20, 2006 8:46 pm

James Bott wrote:As I expect you know, TCBrowse is a subclass of TWBrowse. aAction is eval'd in method lButtonDown in TWBrowse. In TCBrowse, the method has been completely rewritten and aAction is not used anywhere in the method. So, it looks like it will require a significant rewrite of this method to get actions working.

You might consider using TSBrowse instead. I does everything TCBrowse does and a lot more including header actions. You can get a copy at my website.

James


Thank you but I would prefer to not use TSBrowse. Anyway, are you saying that TCBrowse doesn't offer header clicking actions? It would be weird as when the pointer moves over headers it becomes the hand icon and there would be no reason for this.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TCBrowse: clicking on headers

Postby Enrico Maria Giordano » Fri Jan 20, 2006 10:43 pm

A partial fix could be (TCBrowse:LButtonDown() method):

Code: Select all  Expand view  RUN
   if ::nLen < 1
      return nil
   endif
//EMG
   if nClickRow == 0 .and. Valtype(nKeyFlags) == "N"
      if ::aActions != nil .and. ;
         ( nAtCol := ::nAtCol( nColPix ) ) <= Len( ::aActions )
            if ::aActions[ nAtCol ] != nil
               Eval( ::aActions[ nAtCol ], Self, nRowPix, nColPix )
            else
               MsgBeep()
            endif
      else
         MsgBeep()
      endif
   endif
//EMG
   if nClickRow > 0 .and. nClickRow != ::nRowPos .and. ;


and comment out

Code: Select all  Expand view  RUN
//   Super:LButtonDown( nRowPix, nColPix, nKeyFlags )

return 0


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Fri Jan 20, 2006 11:18 pm

Enrico,

I have implemented a quick fix this way:

Code: Select all  Expand view  RUN
METHOD LButtonUp( nRowPix, nColPix, nFlags ) CLASS TCBrowse

   local nClickRow, nDestCol, nAtCol

   if ::lDrag
     if ::lColDrag
        ::lDrag := .f.
     else
        return Super:LButtonUp( nRowPix, nColPix, nFlags )
     endif
   endif

   if ::lCaptured
      ::lCaptured = .f.
      ReleaseCapture()
      if ::lLineDrag
        ::lLineDrag := .f.
        ::VertLine()
      else
        ::lColDrag := .f.
        nClickRow = nTCWRow( ::hWnd, ::hDC, nRowPix,;
                      If( ::oFont != nil, ::oFont:hFont, 0 ) )

        nDestCol := ::nAtCol(nColPix)
        // we gotta be on header row within listbox and not same colm
        if nClickRow == 0 .and. nColPix > ::nLeft .and. ;
           nColPix < ::nRight - 16 .and. ::nDragCol != nDestCol
             ::Exchange( ::nDragCol, nDestCol)
        else
          if ::aActions != nil .and. ;
             ( nAtCol := ::nAtCol( nColPix ) ) <= Len( ::aActions )
             if ::aActions[ nAtCol ] != nil
                Eval( ::aActions[ nAtCol ], Self, nRowPix, nColPix )
             endif
          endif
        endif
      endif
   endif

   Super:LButtonUp( nRowPix, nColPix, nFlags )

return nil
regards, saludos

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

Postby Enrico Maria Giordano » Fri Jan 20, 2006 11:24 pm

Thank you!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Wed Feb 15, 2006 5:44 pm

Headers clicking still doesn't work on the February build.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Wed Feb 15, 2006 5:56 pm

Enrico,

Please try fwh\samples\enrico.prg :)

Its working fine :)
regards, saludos

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

Postby Enrico Maria Giordano » Wed Feb 15, 2006 7:04 pm

Antonio Linares wrote:Enrico,

Please try fwh\samples\enrico.prg :)

Its working fine :)


Ok, but try this enrico2.prg:

Code: Select all  Expand view  RUN
#include "Fivewin.ch"
#include "Tcbrowse.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw, oCol

    USE Customer ALIAS Test

    DEFINE DIALOG oDlg SIZE 300, 300

    @ 0, 0 BROWSE oBrw

    ADD COLUMN TO oBrw;
               DATA TEST -> last;
               HEADER "LAST";
               COLOR CLR_RED, CLR_GREEN

    ADD COLUMN TO oBrw;
               DATA TEST -> first;
               HEADER "FIRST";
               COLOR CLR_RED, CLR_GREEN

    oBrw:lCellStyle = .T.
    oBrw:lMChange = .F.

    oBrw:aActions = { { || MsgInfo( "One!" ) }, { || MsgInfo( "Two!" ) } }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER ;
             VALID MsgYesNo( "Want to exit ?" )

    CLOSE

    RETURN NIL


:lol:

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Wed Feb 15, 2006 8:57 pm

Enrico,

This line is causing the problem:

oBrw:lMChange = .f.

but here you have a modified Class TCBrowse that works ok with your sample: http://hyperupload.com/download/a4efe52 ... e.prg.html :)
regards, saludos

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

Postby Enrico Maria Giordano » Wed Feb 15, 2006 9:29 pm

Thank you.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 94 guests