TMSFMXTreeView CheckType and KeyBoard Input

Hi,


I currently have some columns of some nodes in a TreeView with  CheckTypes set to tvntCheckBox for some rows in my TreeViews.

This gives me what I want in that there is a checkbox and I use the Before/After Check/UnCheck events to edit my underlying data in response to checking.

One of my clients has a few users that very rarely use the mouse to do things and use tab/enter etc to move around. Currently normal CheckBoxes in Delphi will toggle there state if you press the space bar when they are focused, but I can't seem to find any way to check the checkbox in the grid only using the keyboard. 

Is this an option / event I am missing somewhere, or is it not possible?

Thanks






I see no issue here using the spacebar to toggle the checkbox on nodes.
See example where in the first group checkboxes were added for nodes.
Select (focus) any of these nodes and press spacebar to toggle the node.
Test project: http://www;tmssoftware.net/public/TMSFMXTreeviewCheck.zip 

Apologies for the delay, I didn't check the forum to see your response.


Thanks for the example, I can see what I am doing differently now.

If you put the check box in a different column (other than the first eg.. year in your example data) I am not able to check it via the keyboard. If this is a simple fix for you that would be great if you can make an update. 

Otherwise I could try to rearrange the columns to have the checkbox at the start, but sometimes it would still not be possible as we might have multiple check columns that they tab through and check or uncheck individually.


Hi,


This is unfortunately not supported. Only the first one can be checked with the keyboard. But you are correct about tabbing with the keyboard, yet this is perhaps a functionality that needs to be optional, as tabbing now jumps to another component.

Thanks for the response.


I have completely disabled delphi / fmx's tabbing... because it doesn't work when you use frames as far as I can tell. Or possibly just with frames and components created at runtime not design time.

So I have implemented my own tabbing procedure which is working okay.

With multiple custom editor types for text and numbers etc in different columns I am able to tab through your grids quite well. It just doesn't work on the checkboxes.

I will try replacing the check type with a custom editor that is a checkbox and see how that goes as I am running into other problems with the keyboard entry with the check column in the first column.

Seems like there is a bug in HandleNodeToggleCheck


It only checks if the column is of tvtCheckBox type when it is trying to uncheck the column, so it does internally check the node even if it is not.


hmmm further problem (not sure if its fair to call this one a bug)...


At the end of TTMSFMXCustomTreeView.HandleKeyDown

you do;

    else if spc then
      HandleNodeToggleCheck(sel, 0);

//    FFocusedNode := sel;
//    if donext then
//      ScrollToVirtualNode(FFocusedNode, True, tvnspBottom)
//    else
//      ScrollToVirtualNode(FFocusedNode, True, tvnspTop);


HandleNodeToggleCheck fires AfterCheck (or AfterUnCheck) events which in my case can cause the grid to be refreshed (nodes cleared and re-added from SQL query).

So after that has happened sel is not properly defined (sometimes it selects a random node, sometimes an access violation).

For me commenting out those lines doesn't appear to affect anything... but thats probably because my code selects rows for me anyway.

Is there a reason to completely refresh the nodes collection after checking a node? If this could be avoided then the issue is solved.

It is mostly a bit overkill to refresh the entire grid, but it could be needed.


Basically our system has a designated SQL procedure that is called when a checkbox in a grid is checked/unchecked, actually the SQL procedure to be called is defined in another column in the SQL DataSet. So the program can not know if the grid data is still correct or not.

So usually it just writes a true or a false and the refresh is not needed. But it is just an SQL stored procedure so it could (and in some cases does) write anything it likes.

Since I usually handle re selecting the desired node in our application it is working okay with just commenting out your selection code, but I would really prefer not to have changes in your TMS code as I then need to remember to repeat the changes anytime I update the TMS Pack.

 I do not know what the correct solution really is, I have used timers in other places for this sort of thing to make the Refresh occur after your procedure has finished (I just start a small 50-100ms valued timer in the event). But this is pretty messy and can lead to very difficult debugging.


The TreeView is currently not designed for accessing / viewing datasets. Please make sure the nodes are not cleared when checking or unchecking a node. We'll need to investigate if we can add DB support to the treeview separately. We have added this on our feature request list.