Please try this KISS Sample
Case Scenario 1:
1. Run this demo
2. Press TAB/ENTER to move to grid
3. Press SPACE BAR and change the checkbox value.
4 You can see that CheckBoxClicked Event is not fired!
Case Scenario 2:
1. Run this demo
2. Click on CheckBox of item 2, We have different values for nValue, nCellRowClicked and nCellRowFocused. It is right.
3. Now, move to Grid item 1 or 3 by pressing up/down arrow key
4. Press SPACE BAR and change the checkbox value
5. Now you can see that CheckBoxClicked Event IS fired! We have different values for nValue, nCellRowClicked and nCellRowFocused. nCellRowClicked is wrong IMHO.
What is expected to be done?
In whatever way we do, either by pressing Space bar or mouse click On CheckBoxClicked shall be fired and we shall have a unique value to be checked ( value/cellrowclicked/cellrowfocused) on which row the checkbox value is getting changed.
Code: Select all
#include <hmg.ch>
Function Main
set navigation extended
define window demo at 0, 0 width 400 height 300 main
define textbox t1
row 10
col 10
width 100
end textbox
define grid g1
row 40
col 10
width 330
height 100
widths { 100, 100, 100 }
headers { 'Head1', 'Head2', 'Head3' }
items { { 'Cell11', 'Cell 12', 'Cell 13' }, { 'Cell21', 'Cell 22', 'Cell 23' }, { 'Cell31', 'Cell 32', 'Cell 33' } }
oncheckboxclicked checkboxclicked()
value 1
end grid
define textbox t2
row 150
col 10
width 100
end textbox
end window
demo.g1.checkboxenabled := .t.
demo.center
demo.activate
Return
function checkboxclicked
local nValue := demo.g1.value
local nCellClicked := demo.g1.cellrowclicked
local nCellFocused := demo.g1.cellrowfocused
msginfo( 'Value : ' + alltrim( str( nValue ) ) + ', Cell Clicked : ' + alltrim( str( nCellClicked ) ) + ', Cell Focused : ' + alltrim( str( nCellFocused ) ) )
return nil