TAB in GRID

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 2312
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 555 times
Been thanked: 116 times
Contact:

TAB in GRID

Post by serge_girard » Wed May 01, 2019 7:30 pm

Hello,

I have this grid:

Code: Select all

   DEFINE GRID          Grid_1
      ROW               110
      COL               10
      WIDTH             400     
      HEIGHT            690
      HEADERS           {'Del', 'key 1 ', "attr 1", 'attr 2'  } 
      WIDTHS            { 50,    100,         150,     90    } 
      JUSTIFY           {GRID_JTFY_LEFT , GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_RIGHT    }   
		CELLNAVIGATION    .T.
		COLUMNWHEN        {  { || .T.}, {|| Empty ( This.CellValue )  },  { || .T. }, {|| .T.}  } 
		COLUMNCONTROLS    {{ 'CHECKBOX', 'Yes' , 'No' }, ;																 
								 { 'TEXTBOX',  'CHARACTER'}, ;																
								 { 'TEXTBOX',  'CHARACTER'}, ;																
								 { 'TEXTBOX',  'CHARACTER'} }		  														   
		ALLOWEDIT         .T.
      ITEMS             {} 
      BACKCOLOR         WHITE
      ON HEADCLICK      { {|| Sort_Grid_1(1)}  , { || Sort_Grid_1(2)} ,{|| Sort_Grid_1(3)} ,{|| Sort_Grid_1(4)} }
      ON KEY TAB        ACTION HMG_PressKey( 17, 9)
   END GRID  
Items are loaded after END WINDOW.

Now I want to 'navigate' from a cell to a next cell2 by pressing the TAB-key.
SET NAVIGATION STANDARD doesn't help me nor does SET NAVIGATION EXTENDED.

The TAB key goes from this grid to a button.
How can I make the tab key working from cell to cell, and shift-tab to the previous cell?

Thanks, Serge

KDJ
Posts: 216
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 260 times

Post by KDJ » Wed May 01, 2019 9:15 pm

Hello Serge

This is a simple way:

Code: Select all

ON KEY TAB       ACTION HMG_PressKey(VK_RIGHT)
ON KEY SHIFT+TAB ACTION HMG_PressKey(VK_LEFT)
This is an extended way:

Code: Select all

ON KEY TAB       ACTION TabAction(.F.)
ON KEY SHIFT+TAB ACTION TabAction(.T.)

FUNCTION TabAction(lShift)
  LOCAL nRow      := GetProperty("Main_WA" , "Comp_GR", "CellRowFocused")
  LOCAL nCol      := GetProperty("Main_WA" , "Comp_GR", "CellColFocused")
  LOCAL nRowCount := GetProperty("Main_WA" , "Comp_GR", "ItemCOUNT")
  LOCAL nColCount := GetProperty("Main_WA" , "Comp_GR", "ColumnCOUNT")

  IF lShift
    IF nCol == 1
      IF nRow > 1
        --nRow
        nCol := nColCount
      ENDIF
    ELSE
      --nCol
    ENDIF
  ELSE
    IF nCol == nColCount
      IF nRow < nRowCount
        ++nRow
        nCol := 1
      ENDIF
    ELSE
      ++nCol
    ENDIF
  ENDIF

  SetProperty("Main_WA" , "Comp_GR", "VALUE", {nRow, nCol})

RETURN NIL

User avatar
serge_girard
Posts: 2312
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 555 times
Been thanked: 116 times
Contact:

Post by serge_girard » Thu May 02, 2019 5:52 am

Thanks!

Code: Select all

ON KEY TAB       ACTION HMG_PressKey(VK_RIGHT)
ON KEY SHIFT+TAB ACTION HMG_PressKey(VK_LEFT)
This will do my job!

Serge

Post Reply