From: Glenn W Munroe <gwm@fo...> - 2004-01-16 16:04:10
>>Personally, I would prefer SelectAll over Select(-1). Is it necessary?
>Is it idiomatic? Traditionally in Perl, indexing with -1 means "one
>the end of the array". And -1 is kind of magic (in a bad way), whereas
>SelectAll is very explicit, clear and obvious in a nice way.
Thanks for the feedback, guys. So far, it seems the vote is 2-0 in
favour of SelectAll, though perhaps I should have explained more. My
choice of Select(-1) was driven by the fact that this is the "natural"
way of acting on the entire list, given that the underlying
LVM_SETITEMSTATE message uses an index of -1 to apply a change to the
whole list. Implementing a Deselect() method is trivial, but with the
trivial implementation, passing an index of -1 would deselect all items,
because of the way LVM_SETITEMSTATE works. Select(-1) doesn't work at
the moment only because the current Select() method both selects and
sets focus to the given item. As only one item can have focus, the call
to LVM_SETITEMSTATE with an index of -1 fails. Incidentally, setting
focus is at the heart of where I think the possible bug may lie.
Of course, just because the underlying message works that way doesn't
mean that the method has to. If SelectAll() is considered mote intuitive
and we add a new method, it would be symmetrical to add a DeselectAll()
to go with Deselect(). In that case, should we disable the Deselect(-1)
functionality (remember that this is the "natural" way the message
works) or just leave them both?
Perhaps I'm being too democratic... I'll put the code on Tracker soon
and perhaps Steve or Laurent can take a look and see what they think.
Any more thoughts before I do that?