Discussion:
multi-select listbox keyboard navigation is broken ?
(too old to reply)
R.Wieser
2019-01-30 18:19:14 UTC
Permalink
Hello all,

I've got a listbox here which I've made multi-select (using both
LBS_MULTIPLESEL and LBS_EXTENDEDSEL). This works great when using the
mouse. Using the keyboard ? Not so much ... :-(

The problems:

1) The up-down arrow drags the selection with it it from item-to-item
(expected: just the focus rectangle, with the spacebar/shift to
select/deselect).

2) While pressing shift while moving up-down selects multiple items. But
after that any non-shift cursor movement drops the selection again (making
select some, skip some, select some more impossible).

My question: Am I missing some LBS_xxx flag or something, or is the default
select-by-keyboard just (effectivily) broken ?

Regards,
Rudy Wieser
JJ
2019-01-31 03:54:43 UTC
Permalink
Post by R.Wieser
Hello all,
I've got a listbox here which I've made multi-select (using both
LBS_MULTIPLESEL and LBS_EXTENDEDSEL). This works great when using the
mouse. Using the keyboard ? Not so much ... :-(
1) The up-down arrow drags the selection with it it from item-to-item
(expected: just the focus rectangle, with the spacebar/shift to
select/deselect).
2) While pressing shift while moving up-down selects multiple items. But
after that any non-shift cursor movement drops the selection again (making
select some, skip some, select some more impossible).
My question: Am I missing some LBS_xxx flag or something, or is the default
select-by-keyboard just (effectivily) broken ?
Regards,
Rudy Wieser
It's one of those bugs which Microsoft doesn't bother to fix.
R.Wieser
2019-01-31 08:41:34 UTC
Permalink
JJ,
Post by JJ
It's one of those bugs which Microsoft doesn't bother to fix.
More likely a "long ago designed that way and kept that way for the sake of
backward compatibility" one, but yes, that was what I was thinking about
too.

Its just that I had a sliver of hope that the MSDN pages just forgot to
mention the solution or it disappeared (the new "docs." subdomain pages seem
to have some ... "lost in translation" problems. Like the docs to
LB_GETCURSEL mentioning "If no items are selected, it returns zero", which
doesn't make any sense for either a single or multi-select listbox).

Regards,
Rudy Wieser
JJ
2019-02-01 08:23:58 UTC
Permalink
Post by R.Wieser
Its just that I had a sliver of hope that the MSDN pages just forgot to
mention the solution or it disappeared (the new "docs." subdomain pages seem
to have some ... "lost in translation" problems. Like the docs to
LB_GETCURSEL mentioning "If no items are selected, it returns zero", which
doesn't make any sense for either a single or multi-select listbox).
Regards,
Rudy Wieser
I don't see it explain it that way. Which URL was it?
R.Wieser
2019-02-01 09:44:11 UTC
Permalink
JJ,
Post by JJ
I don't see it explain it that way. Which URL was it?
https://docs.microsoft.com/en-us/windows/desktop/Controls/lb-getcursel Last
line just above the "Requirements".

https://docs.microsoft.com/en-us/windows/desktop/controls/lb-getcaretindex
makes the same mistake.

https://docs.microsoft.com/en-us/windows/desktop/Controls/lb-insertstring :
"If this parameter is 1, the string is added to the end of the list". I'm
guessing the "1" lost its minus sign.

https://docs.microsoft.com/en-us/windows/desktop/Controls/lb-setcursel :
Same as above. Also, what does it return when something else than "1"
(or -1) is provided as wParam ? It doesn't say.

And thats from just 17 LB_xxx messages ....
Post by JJ
Neither ListBox or ListView allow mutiple selection ranges using
the SHIFT key.
I (ofcourse) knew of the former, but somehow assumed the latter one would be
more ... "common" (extended ?). And I just checked, not even the "file
explorer" allows it. :-(

No wonder I keeps seeing examples showing two listboxes with "add" and
"remove" buttons in between them. Its the only way to get a multi-selection
in a usable way (other than using ctrl-click a bunch of times I mean)

Thanks for the heads up, means I won't be spending time implementing a
"solution" which isn't.

Regards,
Rudy Wieser

R.Wieser
2019-01-31 13:16:08 UTC
Permalink
This works great when using the mouse.
It turns out I was wrong: *One* shift-select works, but after that only
ctrl-click selects are permitted (or lose the shift-select, just as with the
keyboard).

Maybe I should replace the whole thing with a (much heavier) ListView and be
done with it.

Regards,
Rudy Wieser
JJ
2019-02-01 08:28:06 UTC
Permalink
Post by R.Wieser
It turns out I was wrong: *One* shift-select works, but after that only
ctrl-click selects are permitted (or lose the shift-select, just as with the
keyboard).
Neither ListBox or ListView allow mutiple selection ranges using the SHIFT
key. i.e. selecting a second range of selection is not possible. The SHIFT
based multiple selection relies heavily on the cursor, and in Windows GUI
framework, there's only one cursor.
Loading...