Row/Col coordinates in oBrowse
Posted: Thu May 03, 2012 12:23 pm
Hi Roger,
please, how is it possible to get/retrieve number of column in oBrowse, where is mouse’s cursor just positioned/moved?
I need to know Row/Col coordinates not (only) for correct displaying in oStatusBar object, but for some next/associated tasks in one my app.
TIA & Regards
Zdeno
please, how is it possible to get/retrieve number of column in oBrowse, where is mouse’s cursor just positioned/moved?
I need to know Row/Col coordinates not (only) for correct displaying in oStatusBar object, but for some next/associated tasks in one my app.
TIA & Regards
Zdeno
Code: Select all
#include "dcdialog.ch"
#include "appevent.ch"
**************
Procedure Main()
**************
LOCAL GetList[0], aDir := Directory(), oStatusCursor, oStatusMouse
Private pnRow := 0, pnCol := 0
@ 0,0 DCBROWSE oBrowse SIZE 45,20 DATA aDir ID 'BROWSER' FIT ;
EVAL {|o|o:ItemMarked := {||oStatusCursor:SetCaption("You are in (cursor is into) ROW:" + alltrim(str(oBrowse:RowPos)) + ", COLUMN:" + alltrim(str(oBrowse:ColPos)))}}
* EVAL {|o|o:ItemMarked := {||oStatusCursor:SetCaption("You are in (cursor is into) ROW:" + alltrim(str(oBrowse:RowPos)) + ", COLUMN:" + alltrim(str(oBrowse:ColPos))), ;
* oStatusMouse:SetCaption("You are in (mouse is over) ROW:" + alltrim(str(M->pnRow)) + ", COLUMN:" + alltrim(str(M->pnCol)))} } ;
DCBROWSECOL ELEMENT 1 HEADER 'File Name' PARENT oBrowse
DCBROWSECOL ELEMENT 2 HEADER 'File Size' PARENT oBrowse
DCBROWSECOL ELEMENT 3 HEADER 'File Date' PARENT oBrowse
DCBROWSECOL ELEMENT 4 HEADER 'File Time' PARENT oBrowse
@ 22, 1 DCSAY '' SAYSIZE 50 SAYOBJECT oStatusCursor ID 'STATUSCURSOR'
@ 23, 1 DCSAY '' SAYSIZE 50 SAYOBJECT oStatusMouse ID 'STATUSMOUSE'
DCREAD GUI FIT MODAL ;
HANDLER MyHandler REFERENCE GetList ;
EVAL { |o| SetAppWindow(o), ;
SetAppFocus( oBrowse ) ;
}
RETURN
*
******************
FUNCTION MyHandler( nEvent, mp1, mp2, oXbp, oDialog, GetList )
******************
Local oBrowse := DC_GetObject( GetList, 'BROWSER' )
Local nCurrentRow := oBrowse:RowPos
Local nCurrentCol := oBrowse:ColPos
Local oStatusCursor := DC_GetObject( GetList, 'STATUSCURSOR' )
Local oStatusMouse := DC_GetObject( GetList, 'STATUSMOUSE' )
M->pnRow := 0
M->pnCol := 0
oStatusMouse:SetCaption("You are in (mouse is over) ROW:" + alltrim(str(M->pnRow)) + ", COLUMN:" + alltrim(str(M->pnCol)))
If ( nEvent == xbeP_Keyboard )
* oStatusCursor:SetCaption("You are in (cursor is into) ROW:" + alltrim(str(nCurrentRow)) + ", COLUMN:" + alltrim(str(nCurrentCol)) )
IF mp1 == xbeK_ESC
RETURN DCGUI_EXIT_ABORT
ELSE
RETURN DCGUI_NONE
ENDIF
Else && mouse events
If ( nEvent == xbeP_Close )
RETURN DCGUI_EXIT_ABORT
ElseIf ( nEvent == xbeM_Motion ) .and. ( oXbp:className() == 'XbpCellGroup' )
M->pnRow := oXbp:CellFromPos(mp1)
M->pnCol := 0 && ???
oStatusMouse:SetCaption("You are in (mouse is over) ROW:" + alltrim(str(M->pnRow)) + ", COLUMN:" + alltrim(str(M->pnCol)))
* nCurrentPos := oXbp:CurrentPos()
* nCurrentRow := oXbp:CellFromPos(mp1)
* aCellPos := oXbp:CellRect(nCurrentRow)
* dcdebug nCurrentRow, nCurrentCol, aCellPos, nCurrentPos
* cContent := oXbp:GetCell(nCurrentRow /*oXbp:CellFromPos(mp1)*/ )
* dcdebug cContent
* x:=DC_GetColArray(2,oBrowse)
* x:=oBrowse:arrayElement
* x:=oBrowse:colpos
* x:=Int((oXbp:currentSize()[2]-mp1[2]) / (oXbp:CellRect(1)[4]-oXbp:CellRect(1)[2]))
* dcdebug x
* oBrowse:refreshCurrent()
SetAppFocus( oBrowse )
RETURN DCGUI_IGNORE
ElseIf ( nEvent == xbeM_LbDown ) .and. ( oXbp:className() == 'XbpCellGroup' )
lLbDown := .T.
* dcdebug 'LbDown', lLbDown
RETURN DCGUI_IGNORE
ElseIf ( nEvent == xbeM_LbUp ) .and. ( oXbp:className() == 'XbpCellGroup' )
lLbDown := .F.
* dcdebug 'LbUp', lLbDown
RETURN DCGUI_IGNORE
ElseIf ( nEvent == xbeM_LbDblClick ) .and. ( oXbp:className() == 'XbpCellGroup' )
RETURN DCGUI_IGNORE
ElseIf ( nEvent == xbeP_KillInputFocus )
RETURN DCGUI_IGNORE
EndIf
EndIf
RETURN DCGUI_NONE
*
* EOF