Often we write all kinds of code for a case we don't want to have happen. For example, a UI where a list controls what is viewed in other parts of the UI. Often, there is no real use of never having something selected. But hey, lists can have no selection, so we code our UI to deal with the null selection, showing no associated widgets (or disabling them) when nothing is selected. Wouldn't it just be easier to never let the list be deselected?
Happily this is quite easy in VisualWorks. Simply add a validation in the properties tool as such:
Then in your ApplicationModel, you implement that method as:
verifyStillSelected: aSequenceController
^aSequenceController view targetIndex ~= aSequenceController view selectionIndex
Basically, unless we're selecting something different than the current selection, we void the selection, because it would end up toggling it off.