You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

carlosp

Beginner

  • "carlosp" started this thread

Posts: 4

Date of registration: Feb 21st 2011

  • Send private message

1

Monday, February 21st 2011, 2:43pm

jbgrid

Hello all,

Can JBGRID edit cell's without using the mouse?



Carlos.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Monday, February 21st 2011, 4:12pm

The "Parent" of a JBGrid is a JTable which knows ClientProperties.

Look at the following sample:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Option Explicit

Public Sub Form_Load()
   Dim row As Integer
   Dim col As Integer 
   Dim rowIndex As Integer = 2
   Dim columnIndex As Integer = 3
 
   JBGrid1.Parent.putClientProperty "JTable.autoStartsEdit", java#lang#Boolean.TRUE 
      
   JBGrid1.Cols = 4
   JBGrid1.Rows = 16
   JBGrid1.SelectionMode = flexSelectionFree
   JBGrid1.Editable= jbEditOnClick
   
   For row = 0 To JBGrid1.Rows - 1
      For col = 0 To JBGrid1.Cols - 1
         
         JBGrid1.DataMatrix(row, col) = row & ";" & col
         JBGrid1.DataMatrix(row, col).CanGetFocus = True
         JBGrid1.DataMatrix(row, col).Editable= True
         JBGrid1.DataMatrix(row, col).Enabled= True         
         JBGrid1.DataMatrix(row, col).TextAlign= fmTextAlignCenter
      Next col
   Next row
   
   JBGrid1.Refresh
   JBGrid1.Parent.clearSelection() 
   JBGrid1.Parent.changeSelection(rowIndex, columnIndex, False, False) 
   JBGrid1.DataMatrix(rowIndex, columnIndex).Parent.requestFocus
   JBGrid1.DataMatrix(rowIndex, columnIndex).SetFocus
   Me.Refresh
End Sub

Public Sub JBGrid1_KeyPress(KeyAscii As Integer)
   Debug.Print "KeyPress " & KeyAscii
End Sub

Public Sub JBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
   Debug.Print "KeyDown " & KeyCode & " " & Shift
End Sub


It probably takes some event handling to establish proper keyboard handling.

Please post your findings.

Greetings

A1880

carlosp

Beginner

  • "carlosp" started this thread

Posts: 4

Date of registration: Feb 21st 2011

  • Send private message

3

Wednesday, February 23rd 2011, 2:49pm

Hello A1880,



What i'm looking for, is when i press a key form the keyboard, trigers the edit of the grid.



thanks.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Wednesday, February 23rd 2011, 3:21pm

Yes, that is what I was trying to demonstrate with my sample.

The "JTable.autoStartsEdit" property is responsible for how the JTable in JBGrid reacts on keyboard events.

It probably takes some experiments to get this to work properly.
Read the source code of JBGrid in the Jabaco framework to find out about the inner workings.

Greetings

A1880

carlosp

Beginner

  • "carlosp" started this thread

Posts: 4

Date of registration: Feb 21st 2011

  • Send private message

5

Wednesday, February 23rd 2011, 3:26pm

when i press key in your exemple nothing hapends... ?(

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

6

Wednesday, February 23rd 2011, 3:42pm

To get a reaction of JBGrid, the JBGrid1 control has to have the "focus".
I am not sure how to set the focus automatically.

To find out what is happending, you could add event handlers and issue "debug.print" statements which show
the presence of the events.

As mentioned in my previous post: It takes additional thought and experiments to get this to work.

What do you want to achieve? A 0% mouse and 100% keyboard usage?

A1880

carlosp

Beginner

  • "carlosp" started this thread

Posts: 4

Date of registration: Feb 21st 2011

  • Send private message

7

Wednesday, February 23rd 2011, 3:51pm

"What do you want to achieve? A 0% mouse and 100% keyboard usage?

A1880 "




yes that's i want...



carlos.








Rate this thread
WoltLab Burning Board