capi:list-panel selection-callback issues
Hi
Situation
I use list-panels to show items depending on the selection in a previous list-panel.
For example: list-panel 1 shows body regions. Depending on the selection of the body region in list-panel 1, the second list-panel has to show a list of possible sub-regions for that body region.
If a sub-region is selected, a third list-panel shows the muscles in that sub-region.
All data is displayed in the lists, however, there seems to be a challenge with selection.
I’m using LispWorks 7.0 Pro (32-bit) in a Mac (OS X 10.10.5 Yosemite)
One item in the list-panel
If there is only one possible sub-region, it is displayed in the second list-panel.
Then the user may decide if he/she wants to see the muscles for this sub-region or not.
Say, the user wants to see more and selects it … nothing happens because the selection-callback is not activated.
Thus, if the list-panel only has one item, you first have to click somewhere in the list-panel to deselect the item (the retract callback is called then) and the select it again. Then the selection-callback is activated, which in my case populates the third list-panel with muscle names.
Multiple items in the list-panel
When there are many sub-region, they are displayed in the second list-panel, with the first item in grey (auto selected by the system).
However, the user did not select this one, so the muscle list-panel doesn’t show any items.
When the user clicks on this ‘grey’ item, the selection-callback is not called.
Again, first the users needs to select an item he/she doesn’t want to see and then select the first item again.
Only then is the selection-callback called.
The CAPI User Manual on page 338 writes:
“With interaction :single-selection, the choice can only have one item selected at a time. When a new selection is made, the old selection is cleared and its selection-callback is called.
The selection-callback is also called when the user invokes the selection gesture on the selected item.”
The last sentence suggests that when clicking on a selected item, the selection-callback is called again?
Which it isn’t.
Question: how to let the list-panel call the selection-callback of an item even if it was already selected by the user, or the system?
i.e. it always calls the selection-callback even when selected before.
Or even shorter, when selecting an item in a list-panel with the mouse, always call the selection-callback.
The code below from the user manual is presenting this issue.
Just click on the selected item. The selection-callback is not fired.
Example 1 - one item
(capi:contain (make-instance
'capi:list-panel
:items '(:grey)
:print-function 'string-capitalize
:interaction :single-selection
:selection-callback
#'(lambda (data interface) (capi:display-message "~S" data))))
Example 2 - multiple items
(setq capi-test (capi:contain (make-instance
'capi:list-panel
:items '(:red :blue :green)
:print-function 'string-capitalize
:interaction :single-selection
:selection-callback
#'(lambda (data interface) (capi:display-message "~S" data)))))
When you use the following function to change the selection:
(capi:apply-in-pane-process
list #'(setf capi:choice-selected-item) ':green capi-test)
This does not activate the selection-callback. Try now to click on the newly selected item. The selection-callback is not called.
After many hours of trying, I ran out of ideas.
Any hints and tips would be greatly appreciated.
Thanks,
Kris