Page 1 of 1
TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 6:56 pm
by Enrico Maria Giordano
In the following sample nothing happens when the headers are clicked. Why? How can I trap this event?
Code: Select all
#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
Posted: Fri Jan 20, 2006 8:34 pm
by James Bott
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
Posted: Fri Jan 20, 2006 8:46 pm
by Enrico Maria Giordano
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
Re: TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 10:43 pm
by Enrico Maria Giordano
A partial fix could be (TCBrowse:LButtonDown() method):
Code: Select all
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
// Super:LButtonDown( nRowPix, nColPix, nKeyFlags )
return 0
EMG
Posted: Fri Jan 20, 2006 11:18 pm
by Antonio Linares
Enrico,
I have implemented a quick fix this way:
Code: Select all
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
Posted: Fri Jan 20, 2006 11:24 pm
by Enrico Maria Giordano
Thank you!
EMG
Posted: Wed Feb 15, 2006 5:44 pm
by Enrico Maria Giordano
Headers clicking still doesn't work on the February build.
EMG
Posted: Wed Feb 15, 2006 5:56 pm
by Antonio Linares
Enrico,
Please try fwh\samples\enrico.prg
Its working fine
Posted: Wed Feb 15, 2006 7:04 pm
by Enrico Maria Giordano
Antonio Linares wrote:Enrico,
Please try fwh\samples\enrico.prg
Its working fine
Ok, but try this enrico2.prg:
Code: Select all
#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
EMG
Posted: Wed Feb 15, 2006 8:57 pm
by Antonio Linares
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
Posted: Wed Feb 15, 2006 9:29 pm
by Enrico Maria Giordano
Thank you.
EMG