The following sample shows click events for rows greater than 12:
Cheers
A1880
|
|
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 |
Option Explicit Public Sub JBGrid1_Click() MsgBox "clicked!" End Sub Public Sub Form_Load() Dim row As Integer Dim col As Integer Dim rowIndex As Integer = 2 Dim columnIndex As Integer = 3 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 |
Cheers
A1880
Hey everybody,
I can't get this to work! It seems like it doesn't matter whether row > 12 or < 12.
The Click() or DblClick() event is only fired for rows that have been within a visible range!
As soon as rows are affected by the vertical scroll pane there is no Click() event.
Try the above sample and set JBGrid1.Height = 90 !
On rows > 6 I don't get events!
I actually need the DblClick() event to be fired else I could just use the MouseUp() event but how could I catch the DblClick() over the JBGrid there or else?
Or maybe there is some way to go through JBGrid1.Parent.... that I haven't found yet?
Does anybody know how to work around this?
Is there any other post about this?
Dani
I can't get this to work! It seems like it doesn't matter whether row > 12 or < 12.
The Click() or DblClick() event is only fired for rows that have been within a visible range!
As soon as rows are affected by the vertical scroll pane there is no Click() event.
Try the above sample and set JBGrid1.Height = 90 !
On rows > 6 I don't get events!
I actually need the DblClick() event to be fired else I could just use the MouseUp() event but how could I catch the DblClick() over the JBGrid there or else?
Or maybe there is some way to go through JBGrid1.Parent.... that I haven't found yet?
Does anybody know how to work around this?
Is there any other post about this?
Dani
That's weird!
The MouseDown event gets triggered as expected:
The DoubleClick might be devoted to cell editing.
Greetings
A1880
The MouseDown event gets triggered as expected:
|
|
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 JBGrid1_Click() Debug.Print "clicked!" End Sub Public Sub JBGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "Mouse Down " & JBGrid1.Parent.getSelectedRow & ";" & JBGrid1.Parent.getSelectedColumn End Sub Public Sub Form_Load() Dim row As Integer Dim col As Integer Dim rowIndex As Integer = 2 Dim columnIndex As Integer = 3 JBGrid1.Cols = 4 JBGrid1.Rows = 16 JBGrid1.RowHeightGlobal = 64 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 |
The DoubleClick might be devoted to cell editing.
Greetings
A1880
Click and dblClick on JBGrid and its header
Hey there A1880,
I kind of figured you would be there...
Well I got a solution for now!
It might not be very elegant but it works for me. I need the grid to be set to JBGrid1.Editable = jbNotEditable
Anything else does not work well with this solution !!
Also the MouseDown() event gets fired twice on the dblClick. But that could be worked around easyly.
happy that the .Parent (s) are there
Dani
I kind of figured you would be there...
Well I got a solution for now!
|
|
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
Option Explicit Implements java#awt#Event#MouseListener Public Sub JBGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "Mouse Down " & JBGrid1.Parent.getSelectedRow & ";" & JBGrid1.Parent.getSelectedColumn End Sub Public Sub Form_Load() Dim row As Integer Dim col As Integer Dim rowIndex As Integer = 2 Dim columnIndex As Integer = 3 JBGrid1.Parent.getTableHeader().addMouseListener(Me) JBGrid1.Parent.addMouseListener(Me) JBGrid1.Height =400 JBGrid1.Cols = 4 JBGrid1.Rows = 16 JBGrid1.RowHeightGlobal = 64 JBGrid1.SelectionMode = flexSelectionFree JBGrid1.Editable= jbNotEditable For row = 0 To JBGrid1.Rows - 1 For col = 0 To JBGrid1.Cols - 1 If JBGrid1.Header(JBGrid1.Cols - 1)= "" Then JBGrid1.Header(col) = col 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 mouseClicked(arg2 As MouseEvent) ' capture a single click on the table header for sorting! If arg2.getY < JBGrid1.HeaderHeight Then Debug.Print "header clicked " & JBGrid1.Header(JBGrid1.Parent.getColumnModel.getColumnIndexAtX(arg2.getX)) End If ' capture dblclick on rows you have to scroll to!! If arg2.getClickCount = 2 Then Debug.Print "dblclicked " & JBGrid1.Parent.getSelectedRow & ";" & JBGrid1.Parent.getSelectedColumn End Sub Public Sub mousePressed(arg2 As MouseEvent) End Sub Public Sub mouseReleased(arg2 As MouseEvent) End Sub Public Sub mouseEntered(arg2 As MouseEvent) End Sub Public Sub mouseExited(arg2 As MouseEvent) End Sub |
It might not be very elegant but it works for me. I need the grid to be set to JBGrid1.Editable = jbNotEditable
Anything else does not work well with this solution !!
Also the MouseDown() event gets fired twice on the dblClick. But that could be worked around easyly.
happy that the .Parent (s) are there
Dani
I just realized that depending on from where the mouse is moving towards the grid header you get different values for arg2.getY ! Aproaching from S you get values <= JBGrid1.HeaderHeight over the first row.
You can also use:
I really don't like it very much since "JTableHeader" might change in a different versions or else!
to be continued I guess ....
Dani
You can also use:
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 |
Public Sub mouseClicked(arg2 As MouseEvent) ' capture a single click on the table header for sorting! ' If arg2.getY < JBGrid1.HeaderHeight Then If InStr(arg2.getComponent,"JTableHeader") Then Debug.Print "header clicked " & JBGrid1.Header(JBGrid1.Parent.getColumnModel.getColumnIndexAtX(arg2.getX)) End If ' capture dblclick on rows you have to scroll to!! If arg2.getClickCount = 2 Then Debug.Print "dblclicked " & JBGrid1.Parent.getSelectedRow & ";" & JBGrid1.Parent.getSelectedColumn End Sub |
I really don't like it very much since "JTableHeader" might change in a different versions or else!
to be continued I guess ....
Dani
I had simelar trouble: a click on a JBGrid row higher then 12 did not do anything. With your help and these lines it works:
"Die richtig fiesen Bugs kommen immer erst kurz vor Schluß zutage..."
Thanks A1880
Quoted
![]()
Source code
1 2 3 4 5 Implements java#awt#Event#MouseListener Public Sub JBGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "Mouse Down " & JBGrid1.Parent.getSelectedRow & ";" & JBGrid1.Parent.getSelectedColumn End Sub and JBGrid1.SelectionMode = flexSelectionFree JBGrid1.Editable= jbNotEditable 'und diese Zeile ist besonders fies...aber aus irgend einem buggy Grund wohl nötig
"Die richtig fiesen Bugs kommen immer erst kurz vor Schluß zutage..."
Similar threads
-
General topics, questions and discussions »-
Jabaco JBGRID
(Dec 28th 2009, 9:37pm)
-
Tips, Tricks, Samples & Tutorials »-
Event handler
(Jan 4th 2010, 9:06am)
-
General topics, questions and discussions »-
Using ActionListener in Jabaco
(Aug 13th 2009, 10:12pm)
-
Allgemeine Themen, Fragen und Diskussionen »-
Allgemeine Fragen zu Forms (Open und Close)
(Nov 25th 2008, 11:07am)
