Page 1 of 1

HMG4 GRID problem

Posted: Thu Sep 29, 2011 3:07 pm
by Ricci
Does anyone know why the cursor keys are not working in a grid? Neither in my program nor in the demos.

Re: HMG4 GRID problem

Posted: Thu Sep 29, 2011 3:19 pm
by mrduck
Ricci wrote:Does anyone know why the cursor keys are not working in a grid? Neither in my program nor in the demos.
It's the same problem that was in virtualgrid.

In METHOD DoKeyBoardEvents( e ) CLASS GRID change all the RETURN .T. into RETURN .F. in all places where the event is not handled by the method and should be passed back to Qt, for example here:

Code: Select all

   IF !::lAllowEdit .or. ::lMultiSelect
   // Nothing doing
      RETURN .T.     <======== must be .F.
After a quick look at the code, the 5 RETURN in the method should return
.T. .F. .F. .T. .F.

Re: HMG4 GRID problem

Posted: Thu Sep 29, 2011 3:21 pm
by mrduck
Anyway, GRID class needs a bit of code refactoring....

Re: HMG4 GRID problem

Posted: Thu Sep 29, 2011 3:57 pm
by Ricci
Thank you.

2 minor problems:

1. If a GRID or VirtualGrid contains only 1 record than the header ist always blue, even if it has the focus or not.

2. If you use :ColumnJustify { .... } in GRID the text in all cells is vertical top aligned. See Demo_3 in GRID samples.

Re: HMG4 GRID problem

Posted: Thu Sep 29, 2011 8:05 pm
by Ricci
I found the solution for the display problem with :ColumnJustify

In grid.prg this part in METHOD Cell should be changed:

Code: Select all

      ELSEIF Pcount() == 3
         oItem := QTableWidgetItem()
         IF ValType( ::aColumnJustify ) != 'U'
            DO CASE
               CASE ::aColumnJustify[nCol] == GRID_JTFY_LEFT
                  oItem:setTextAlignment( Qt_AlignLeft )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_RIGHT
                  oItem:setTextAlignment( Qt_AlignRight )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_CENTER
                  oItem:setTextAlignment( Qt_AlignHCenter )
            ENDCASE
         ENDIF
to

Code: Select all

      ELSEIF Pcount() == 3
         oItem := QTableWidgetItem()
         IF ValType( ::aColumnJustify ) != 'U'
            DO CASE
               CASE ::aColumnJustify[nCol] == GRID_JTFY_LEFT
                  oItem:setTextAlignment( hb_bitOR( Qt_AlignVCenter, Qt_AlignLeft ) )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_RIGHT
                  oItem:setTextAlignment( hb_bitOR( Qt_AlignVCenter, Qt_AlignRight ) )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_CENTER
                  oItem:setTextAlignment( hb_bitOR( Qt_AlignVCenter, Qt_AlignHCenter ) )
            ENDCASE
         ENDIF