Row color when mouse over

Re: Row color when mouse over

Postby ukoenig » Wed Aug 07, 2013 4:59 pm

As soon it is possible to get the mouse row / col-position,
using a adjusted TOOLTIP,
It can be used for ROWS or CELLS.
You can change the cell-color :

Image

Code: Select all  Expand view

FOR i := 1 TO LEN( oBrw3:aCols )
    WITH OBJECT oBrw3:aCols[i]
        oBrw3:aCols[i]:bToolTip := { | oBrw, nRow, nCol, nFlags | ;
        CELLCHANGE( oBrw, nRow, nCol, nFlags) }
    END
NEXT

STATIC FUNCTION CELLCHANGE( oBrw, nRow, nCol, nFlags )
LOCAL nRow1, nCol1

// Reset to Your original xBrowse-setting, to delete the old mouse-capture-result
// --------------------------------------------------------------------------------------------
oBrw:aCols[ 1 ]:bClrStd := { || { nXBTColor,  } }
oBrw:aCols[ 2 ]:bClrStd := { || { nXBTColor,  } }
oBrw:aCols[ 3 ]:bClrStd := { || { nXBTColor,  } }
// Brush
XBRW_BACK(oBrw, nXBStyle, nXBColorF, nXBColorB, nXBGradPos, lXBDirect, ;
            cXBBrush, cXBImage, nXBStretch )  
// -------

IF oBrw:MouseRowPos( nRow ) > 0
    nRow1 := oBrw:MouseRowPos( nRow )
    nCol1 := oBrw:MouseColPos( nCol )
// shows the row and col - number
//  MsgAlert( "Row : " + ALLTRIM(STR(nRow1)) + CRLF + ;
//                   "Col : " + ALLTRIM(STR(nCol1)), "Position" )
    oBrw:aCols[nCol1]:bClrStd := {|| { IIF( oBrw:KeyNo() = nRow1, 255, nXBTColor), CLR_GRAY } }
ENDIF

RETURN NIL
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Row color when mouse over

Postby FranciscoA » Thu Aug 08, 2013 2:11 am

Uwe,
Your sample is functional for you?
I have not been able to adapt to my code.

If we know the determinate row (eg row 14) on the browse,
can you show us an example for painting the entire row 14?.

We should note that this line is not the registration number, but the current line of the display.
I saw in this forum a lot of examples, but nothing.

Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2132
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Row color when mouse over

Postby FranciscoA » Thu Aug 08, 2013 3:37 am

Uwe and other forum friends.

Thus far I have come.
The oSay on the dialog display correctly the row according to moves of the mouse.

What I could not do, is to paint the currently row where the mouse is over.

Regards.
Code: Select all  Expand view

//TXBROWSE VERSION 1204

   DATA nOldRowMP  AS NUMERIC       // Old Row Mouse Pointer              //FranciscoA
   DATA bMMoved    INIT { || nil }  // Evaluate Block for Lines Colors    //FranciscoA


METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TXBrowse

   local oCol
   local nLen, nFor, nPos
   local cTxt  // tooltip CELL
   local nVMove, nHMove, nOldRowPos,  nOldColPos
   local nMousePos := ::MouseRowPos( nRow )


   if ::bMMoved != nil                 //FranciscoA
     if nMousePos <> ::nOldRowMP       //FranciscoA
        Eval(::bMMoved, nRow, nCol)    //FranciscoA
        ::nOldRowMP := nMousePos       //FranciscoA
     endif                             //FranciscoA  
   endif                               //FranciscoA


   TrackMouseEvent( ::hWnd, TME_LEAVE )



METHOD New( oWnd ) CLASS TXBrowse

   ::nCaptured    := 0
   ::nLastEditCol := 0

   ::nOldRowMP    := 1       //FranciscoA
   ::bMMoved      := NIL     //FranciscoA

   ::nRowDividerStyle := LINESTYLE_NOLINES


//-------------------------
IN PRG

DEFINE DIALOG oDlg SIZE oVent:nWidth, oVent:nHeight TITLE "FapSoftScan" TRANSPARENT

@oDlg:nTop+10,200 SAY oSayPrueba VAR cSayPrueba OF oDlg PIXEL


@1,1 XBROWSE oBrw OF oDlg ;
     ARRAY {} CELL LINES FOOTERS AUTOSORT

     WITH OBJECT oBrw
     ...
     ...
     END

     oBrw:CreateFromCode()

     oBrw:bMMoved := {|nRow,nCol| ClrRowMouseOver(oBrw,nRow,nCol,oSayPrueba) }

ACTIVATE DIALOG oDlg
//-------------------------

//---------------------------------------
Function ClrRowMouseOver(oBrw,nRow,nCol,oSayPrueba)

local n, n1
local nRowMPos := oBrw:MouseRowPos(nRow)  //linea en que esta el mouse
local nDisplRows := oBrw:RowCount()       //lineas visibles en el xBrowse
local bClrStd := oBrw:bClrStd


for n := 1 to nDisplRows
   For n1 := 1 to len(oBrw:aCols)
     if n = nRowMPos
        oSayPrueba:SetText(Str(nRowMPos,4))
        oBrw:aCols[n1]:bClrStd := {|| { nRGB(0,0,0),nRGB(120,50,150)} }
     else
        oBrw:aCols[n1]:bClrStd := bClrStd
     endif
   Next
next
                                                                                             
Return nil
 
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2132
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Row color when mouse over

Postby James Bott » Thu Aug 08, 2013 3:10 pm

I think it is going to be complicated.

There is a drawLine() method. You will have to save the current colors, change them, draw the line, then restore the colors. You may have to save and restore other data such as current line, selected row, etc.

This all has to be triggered by a mouseOver event using bMMoved.

Also, I wonder about doing this. Unless there is a timer used, while the user is moving the mouse cursor around the browse, the line under the cursor would be getting constantly redrawn and this could be very distracting and slow down the browse. If you use a timer delay then this may confuse the user.

What is the reason for wanting to do this? It doesn't seem intuitive to have two lines highlighted. How is the user going to know which is the "selected" row and which isn't? Can't you just use the selected row instead?

I don't think users are going to expect this behavior--I have never seen it before.

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

Re: Row color when mouse over

Postby FranciscoA » Thu Aug 08, 2013 6:37 pm

What is the reason for wanting to do this? It doesn't seem intuitive to have two lines highlighted. How is the user going to know which is the "selected" row and which isn't? Can't you just use the selected row instead?

I don't think users are going to expect this behavior--I have never seen it before.


Image

Mr. Bott,
Thanks for sharing your views.

Two clients of mine have asked me to update their old programs.
One of their requirements is precisely that the browsers have the look of W7. It's a powerful reason, no?

Best regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2132
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Row color when mouse over

Postby James Bott » Thu Aug 08, 2013 9:53 pm

Francisco,

the look of W7. It's a powerful reason, no?


Yes, I must admit that it is. This is news to me.

Since this is a new standard, then I think we need to have it built into the xbrowse class rather than trying to implement it outside of the class. So, I suggest that either Antonio or Nages needs to implement it. It would also be easier to program this inside the class and we can still save class codeblocks like bMMoved for use outside the class.

Of course, it should be an option.

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

Re: Row color when mouse over

Postby FranciscoA » Fri Aug 09, 2013 4:26 pm

Yes, it could be very interesting create the CellMouseOver / CellMouseLeave, and/or RowMouseOver / RowMouseLeave Methods, for TXBrowse.
Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2132
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Row color when mouse over

Postby James Bott » Sun Aug 11, 2013 2:37 pm

Francisco,

Yes, it could be very interesting create the CellMouseOver / CellMouseLeave, and/or RowMouseOver / RowMouseLeave Methods, for TXBrowse.


I think you meant codeblocks?

It would also be nice to just have flags to turn on cell or row highlighting and also color settings for the same. Or maybe a method.

SetMouseOverRow( lOn, nClrFore, aClrPane )

SetMouseOverCell( lOn, nClrFore, aClrPane )

Where aClrPane is an array of one or two colors (two for a gradient).

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

Re: Row color when mouse over

Postby FranciscoA » Sun Aug 11, 2013 3:14 pm

James,
Yes, you are right, that way could be, also.
Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2132
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Row color when mouse over

Postby FranciscoA » Fri Aug 23, 2013 2:57 am

James and other colleagues:
Maybe you want to collaborate to improve it.
viewtopic.php?f=6&t=26903#p150195
Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2132
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 131 guests