libyui / libyui-ncurses

libyui-ncurses
http://doc.opensuse.org/projects/libyui
19 stars 18 forks source link

[Space] key vs. "Activated" Events in Tables with Nested Items #112

Closed shundhammer closed 3 years ago

shundhammer commented 3 years ago

Trello

https://trello.com/c/Ioha5sgR/2231-3-nested-table-expanding-collapsing-is-triggered-together-with-the-activated-event

Bugzilla

https://bugzilla.suse.com/show_bug.cgi?id=1181789

Problem

In the YaST partitioner (which is so far the one and only application for the new "nested table items" feature), the [Space] key not only opens or closes tree branches, it also sends an "Activated" event (the counterpart of double-clicking an item in the Qt UI).

Both actions should be separate:

Fix

Changed the event handler to have definitively separate handling for both keys.

Caution

Event handling on this level may affect a lot of other widgets that are seemingly unrelated. See also

https://github.com/libyui/libyui-ncurses/blob/master/doc/nctable-and-nctree.md

Consistency with Other Widgets

When and if selection widgets send an "Activated" event and how selecting multiple items is handled (MultiSelectionBox, Tree with multi-selection) is not completely consistent in our NCurses UI.

The MultiSelectionBox uses [Return] as well as [Space] for selecting individual items. Changing that would be a regression.

Since the NCTableWidget is closely related to the NCTreeWidget (they both use the NCTablePad class), we need to be very careful not to break the existing behaviour. NCTable* classes support both trees with collapsible / expandable branches AND multi-selection. That means that we have conflicting requirements, and we start running out of keys (that a user might use intuitively).

[Space] is already used to open or close tree branches (in addtion to [+] and [-]), so we can't use that for multi-selection. That leaves [Return] for multi-selection, but that is already commonly used for the "Activated" event, i.e. to start immediate operations on the currently selected item.

The compromise here was to behave like the MultiSelectionBox and the Tree with multi-selection in case the widget is using multi-selection, i.e. [Return] toggles the checkbox of the current item.

If multi-selection is not used (and only then), [Return] sends an "Activated" event.

This is not ideal, but it's a pragmatic compromise.