Instability of Grid Check Box

Moderator: Rathinagiri

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

Instability of Grid Check Box

Post by Rathinagiri »

I have found some instability in Grid CheckBox click event:

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
 
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Instability of Grid Check Box

Post by andyglezl »

Lo siento, tengo la version 3.4
-------------------------------------
Sorry, I have version 3.4


D:\HMG\3.4>build sample1
Harbour 3.2.0dev (r1501091819)
Copyright (c) 1999-2014, "http://harbour-project.org/"
sample1.prg(2494) Error E0030 Syntax error "syntax error at 'CHECKBOXCLICKED'"
1 error
Andrés González López
Desde Guadalajara, Jalisco. México.
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: Instability of Grid Check Box

Post by Rathinagiri »

You have to get 3.4.1 and all the patches (from the download page) to run this demo.
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: Instability of Grid Check Box

Post by srvet_claudio »

Rathinagiri wrote:I have found some instability in Grid CheckBox click event:

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
 
The problem is that CellRowClicked returns always the last row in that you clicked with the mouse and not considered the clicked with keyboard.
I have implemented OnCheckBoxClicked event only with the mouse interface.

Change the original code (h_windows.prg, line 3121) for this:

Code: Select all

               //   OnCheckBoxClicked   (by Dr. Claudio Soto, December 2014)
               #define LVIS_UNCHECKED 0x1000
               #define LVIS_CHECKED   0x2000
               IF GetGridNewState(lParam) == LVIS_UNCHECKED .OR. GetGridNewState(lParam) == LVIS_CHECKED
                  xTemp := { NIL, NIL }
                  xTemp[1] := _HMG_SYSDATA [ 40 ] [ i ] [ 37 ] [ 1 ]   // This.CellRowClicked
                  IF ( xTemp[1] > 0 .AND. xTemp[1] <=  ListView_GetItemCount (_HMG_SYSDATA [ 3 ] [ i ]) ) .OR. ; 
                     ( HMG_GetLastVirtualKeyDown( @xTemp[2] ) == VK_SPACE .AND. xTemp[2] == _HMG_SYSDATA [ 3 ] [ i ] ) 
                     _DoControlEventProcedure ( _HMG_SYSDATA [ 40 ] [ i ] [ 46 ] , i )   // OnCheckBoxClicked
                     Return 0
                  ENDIF
               ENDIF
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
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: Instability of Grid Check Box

Post by Rathinagiri »

Thanks a lot Claudio. I will check this and revert back.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
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: Instability of Grid Check Box

Post by Rathinagiri »

Claudio,

Thank you for the implementation. Now the event is fired even when we use the space bar.

Now, the only problem is, how to find out the CellRowIndex on which the checkbox is mouse clicked/space bar pressed. Is it cellrowclicked or cellrowfocused or value? We should have the same value either by pressing space bar or using mouse click.
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: Instability of Grid Check Box

Post by srvet_claudio »

In the patch 7 viewtopic.php?f=43&t=4400&p=42676#p42676

I did that when you click with the Spacebar:

CellRowClicked = row of the checkbox

CellColClicked = 0
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
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: Instability of Grid Check Box

Post by Rathinagiri »

That will be really great Claudio. Thanks a lot.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
serge_girard
Posts: 3178
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Instability of Grid Check Box

Post by serge_girard »

Thanks Claudio !

Serge
There's nothing you can do that can't be done...
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Instability of Grid Check Box

Post by bpd2000 »

Rathinagiri wrote:That will be really great Claudio. Thanks a lot.
+1
BPD
Convert Dream into Reality through HMG
Post Reply