Repository: godot
Issue: [WIP] Multiple Tree Control issues
Labels: bug,topic:gui

*[WIP: This is mostly a very quick dump of multiple issues from my notes about multiple issues with the Tree control--particularly in relation to keyboard navigation.*
  
*This write-up has been sitting in a tab for a couple of weeks & I diagnosed the original issues back in May but my "TODO" list isn't getting any smaller. :/*
   
*The primary motivation for posting this as is* right now *is because I've noticed that the Tree issues have been encountered by someone who is working on improving accessibility and hopefully the pointers/notes here will be better than nothing even in this state.]*

**Godot version:** ~v3.1.0+

**OS/device including version:** N/A

**Issue description:**

 * Multiple issues (particularly in relation to keyboard navigation) in the Tree control appear to have been introduced when moving from key press processing to action processing in this commit/PR:

   * "Tree now uses UI actions instead of keys "
     https://github.com/godotengine/godot/commit/e3eb6869068edb2617a311f89e93b92a9aa5b905
     a.k.a https://github.com/godotengine/godot/pull/16947 

   From one of the comments it seems the PR may not have been reviewed very closely--which was unfortunate given that tree controls are probably one of the more complex common UI controls.

   (Side note: Given the complexity of the control & implementation I'd recommend that a Tree control specific regression test example project/test script be created to help prevent this situation reoccurring in future. There's a *huge* combinatorial effect here when considering `(mouse control + keyboard control) * (cell select + row select + multi-select) * (custom controls + non-selectable controls + confusing terminology)` etc etc).

   Issues related to this PR include:

     (1) Setting cells to be "non-selectable" appears to break keyboard navigation.
 
```
[TODO: Finish this list from these notes:

# BUG: "selected" naming vs focus & "selected" vs "get_next_selected"
# BUG: Handling non-selectable cells--both selection & cursor focus.
# BUG: Keyboard selecting.
# BUG: Multi-select doesn't emit correct select signals on initial non-mouse selection.
# ~BUG: `set_as_cursor` isn't exposed to GDScript. Which means ~only way to set `selection_item` is via `ui_down` injection.
# BUG: Multi-select LMB click moves cursor column but not cursor row.
# BUG: Multi-select only selects entire rows, not cells in rows, or two partial rows.
# ~BUG: `selected_item = 0` vs `selected_col`
# BUG: Space bar/search issue.
# BUG: Handling of centering/hseparation etc?
# BUG: ...?
]
```

            


  * Other issues:

    (1) Incorrect text centre alignment due to "The default `hseparation` value messes with an (apparent) incorrect centering calculation in `Tree.cpp`." (quoting myself :D )

    (2) Workaround is required to set the cursor position *without* also selecting the cell in multi-select mode (as `set_as_cursor()` is not exposed to GDScript).


**Steps to reproduce:**


**Minimal reproduction project:**
<!-- A small Godot project which reproduces the issue. Drag and drop a zip archive to upload it. -->