Keyboard within grid

Moderator: Rathinagiri

Post Reply
GeoffBarnard
Posts: 11
Joined: Fri Nov 08, 2013 11:28 pm
Location: Guisborough, England
Contact:

Keyboard within grid

Post by GeoffBarnard »

Hello,

I've looked in various places, but not found anything. I've set up a grid, with 1 field/column, and I need to quickly enter data. I'd like to force an 'Enter' immed so I just need to enter data, and then to force a 'Down' after inserting each data item to go to the next line.

I've tried to use Keyboard(..), doesn't seem to do anything.

I've tried it within the grid setup using ON GOTFOCUS which seemed appropriate.

Is there a way to get the grid to be waiting for data entry immed?

Regarding the 'Down' but, does this need the ON CHANGE, and would keyboard() work there?

I've got the key definitions from the .CH file, VK_RETURN and VK_DOWN - or would it need something else?

Any suggestions MUCH appreciated.

Geoff
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Keyboard within grid

Post by Pablo César »

Hi Geoff,

In GUI programming down't work KeyBoard as been in Clipper (console mode).

Please accept my indication, when you need to solve any technical problem, will be important and necessary to post your code, part of it or any simple brief demo. Just to show us how you're doing. When Grids controls, we have different modes. By array, by RowSource (with dbf), Virtual, Multi select, with CELLNAVIGATION property, etc...
GeoffBarnard wrote:Is there a way to get the grid to be waiting for data entry immed?
Grids as all controls are objects, objects not finnish by itself, it is not like Clipper passing thru GETs.
GUI programming is not sequencial mode, all is treated as objects. Only finish when you close window/form or disabling control by your own commands.
GeoffBarnard wrote:Regarding the 'Down' but, does this need the ON CHANGE, and would keyboard() work there?
You mean keyboard down arrow ? If yes, it works to navigate in Grids and ON CHANGE it's a event which will call the function name when be assigned. Then in this your function you do want you want.
GeoffBarnard wrote:I've got the key definitions from the .CH file, VK_RETURN and VK_DOWN - or would it need something else?
I suggest to you, to forget all keyboard controls. Are very hard to work in GUI (not imposible but different). Remeber, GUI programming is handled by mouse events and users normally could clicks at everywhere. So you have to control this events.
GeoffBarnard wrote:Any suggestions MUCH appreciated.
Suggestions ?
Take SAMPLES subfolders in HMG root folder, which contains a lot of examples. Start with basic and try to understand it one by one. Control, by control, events, etc...

And do not be discouraged, do not get frustrated by not understanding something. Post here all your questions, you have many colleagues who can help you. :P

But please be kind to post your code always, please.

B.Rgds
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Keyboard within grid

Post by Javier Tovar »

+1
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Keyboard within grid

Post by Rathinagiri »

I think you want to start editing like Excel in a grid. Is that what you want?

Try to use any of the following option for grid for your purpose:.

Code: Select all

[ EDITOPTION <nEditOption> ]

 

                 nEditOption --> GRID_EDIT_DEFAULT | GRID_EDIT_SELECTALL | GRID_EDIT_INSERTBLANK |

                                 GRID_EDIT_INSERTCHAR | GRID_EDIT_REPLACEALL
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Keyboard within grid

Post by srvet_claudio »

In this demo when you press key down enter in edit mode in the current cell.

Code: Select all


#include "hmg.ch"

Function Main

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 550 ;
      HEIGHT 400 ;
      MAIN

      DEFINE GRID Grid_1 
         ROW      10
         COL      10
         WIDTH    500 
         HEIGHT   330 
         HEADERS  {'Last Name','First Name','Phone'} 
         WIDTHS   {140,140,140}
         ITEMS    LoadItems() 
         CELLNAVIGATION .T.
         ON KEY   TestKey()
      END GRID

   END WINDOW

   Form_1.Center
   Form_1.Activate

Return NIL


FUNCTION TestKey()
LOCAL ret := NIL

   IF HMG_GetLastVirtualKeyDown () == VK_DOWN
      HMG_CleanLastVirtualKeyDown ()
      i:= GetControlIndexByHandle ( EventHWND() )
      IF _HMG_SYSDATA [32] [i] == .T.
         _HMG_GRIDINPLACEKBDEDIT_2(I)
      ELSE
         _HMG_GRIDINPLACEKBDEDIT(I)
      ENDIF
      ret := 1
   ENDIF

RETURN ret


Function LoadItems()
Local aRows [20] [3]

	aRows [1]	:= {'Simpson','Homer','555-5555'}
	aRows [2]	:= {'Mulder','Fox','324-6432'}
	aRows [3]	:= {'Smart','Max','432-5892'}
	aRows [4]	:= {'Grillo','Pepe','894-2332'}
	aRows [5]	:= {'Kirk','James','346-9873'} 
	aRows [6]	:= {'Barriga','Carlos','394-9654'} 
	aRows [7]	:= {'Flanders','Ned','435-3211'} 
	aRows [8]	:= {'Smith','John','123-1234'} 
	aRows [9]	:= {'Pedemonti','Flavio','000-0000'} 
	aRows [10]	:= {'Gomez','Juan','583-4832'} 
	aRows [11]	:= {'Fernandez','Raul','321-4332'} 
	aRows [12]	:= {'Borges','Javier','326-9430'}
	aRows [13]	:= {'Alvarez','Alberto','543-7898'}
	aRows [14]	:= {'Gonzalez','Ambo','437-8473'}
	aRows [15]	:= {'Batistuta','Gol','485-2843'}
	aRows [16]	:= {'Vinazzi','Amigo','394-5983'}
	aRows [17]	:= {'Pedemonti','Flavio','534-7984'}
	aRows [18]	:= {'Samarbide','Armando','854-7873'}
	aRows [19]	:= {'Pradon','Alejandra','???-????'}
	aRows [20]	:= {'Reyes','Monica','432-5836'}

Return aRows
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply