Schatten 290 Posted August 21, 2022 Hey! I have an issue related to ListBox multiple item selection. I've set style property of my list box: style = LB_TEXTURES + LB_MULTI; To use these constants I've included this file: #include "\a3\3den\UI\resincl.inc" Despite that I can't select multiple items with either Shift or Ctrl. Another issue is that if the first item is selected, lbSelection command returns an empty array. This is probably a bug. Can anyone check these issues on their PCs? Share this post Link to post Share on other sites
Larrow 2822 Posted August 22, 2022 Selection/Multi selection via Ctrl or Shift works fine for me, just used import RscListBoxMulti to get the definition for my control. Even tried import RscListBox and #include "\a3\3den\UI\resincl.inc" and changing the style property to style = LB_TEXTURES + LB_MULTI; and everything worked ok. The only thing I did notice is if using lbSelection inside onLBSelChanged, lbSelection returned the previous info (ie it was not updated in time), making the same selection again provided the correct information. Should probably be flagged as a bug as the selection should have already happened. Created ticket. Spoiler #include "\a3\3den\UI\resincl.inc" import RscListBox; //import RscListBoxMulti; class testLB { idd = 10000; class controls { class myLB : RscListBox { idc = 100; x = 0; y = 0; w = 1; h = 1; style = LB_TEXTURES + LB_MULTI; class items { class item0 { text = "0"; }; class item1 { text = "1"; }; class item2 { text = "2"; }; }; onLBSelChanged = " \ params[ '_ctrl', '_index' ]; \ hint format[ 'index: %1, item: %2', _index, _ctrl lbText _index ]; \ systemChat format[ 'Selection: %1', lbSelection _ctrl ]; \ "; }; }; }; 1 Share this post Link to post Share on other sites
Schatten 290 Posted August 22, 2022 Thanks, @Larrow! The problem was that I was updating the list box content in a loop. I've moved the list box populating code outside of the loop and now everything works fine, both multi selection and lbSelection command. Share this post Link to post Share on other sites
killzone_kid 1331 Posted August 28, 2022 There are problems with multiselect listbox, one of which @Larrow has described but there are more Share this post Link to post Share on other sites
Larrow 2822 Posted August 29, 2022 On 8/28/2022 at 8:56 AM, killzone_kid said: but there are more Can you elaborate @killzone_kid ? Share this post Link to post Share on other sites
killzone_kid 1331 Posted August 29, 2022 Next dev will have a few fixes to LB_Multi controls Share this post Link to post Share on other sites
Larrow 2822 Posted August 29, 2022 Cool 👍, I already noticed the changes in Wiki to onLBSelChanged for accessing lbSelection info. Are there any other problems we should consider when using these controls that you know about? Always nice to have this sort of info available. Share this post Link to post Share on other sites
killzone_kid 1331 Posted August 29, 2022 lbselection for non LB_MULTI was bugged. There are minor fixes several of them including crash so wait until dev. Some will make it into hotfix some to 2.12. If you know of any bugs -> ticket + tag me Share this post Link to post Share on other sites
Schatten 290 Posted August 30, 2022 Also, despite BIKI, you can't use lbSetSelected command to deselect all items in LB_MULTI list box -- I had to use lbSetCurSel instead. So either BIKI has wrong info or lbSetSelected is bugged. Share this post Link to post Share on other sites
killzone_kid 1331 Posted August 31, 2022 19 hours ago, Schatten said: Also, despite BIKI, you can't use lbSetSelected command to deselect all items in LB_MULTI list box -- I had to use lbSetCurSel instead. So either BIKI has wrong info or lbSetSelected is bugged. could you point to where it says wrong? can you give example what code doesnt do what you expect? Share this post Link to post Share on other sites
Schatten 290 Posted September 1, 2022 On 8/31/2022 at 11:39 AM, killzone_kid said: could you point to where it says wrong? can you give example what code doesnt do what you expect? Sure. I have such dialog: Spoiler and want to delete list box items and deselect all of them after unloading cargo items. According to BIKI: Quote To deselect all entries, use -1: _ctrl lbSetCurSel -1; For listbox of style LB_MULTI use lbSetSelected instead. My list box has LB_MULTI style, so let's use lbSetSelected: private _netIds = (lbSelection _control) apply { _control lbData _x }; { for "_i" from 0 to ((lbSize _control) - 1) do { if ((_control lbData _i) == _x) exitWith { _control lbDelete _i; }; }; } forEach _netIds; _control lbSetSelected [-1, true]; The result is here: Spoiler Now let's see the result of using lbSetCurSel: Spoiler Share this post Link to post Share on other sites
killzone_kid 1331 Posted September 1, 2022 1 hour ago, Schatten said: lbSetSelected [-1, true] where did you get this code from? Share this post Link to post Share on other sites
Schatten 290 Posted September 1, 2022 31 minutes ago, killzone_kid said: where did you get this code from? I assumed that if to deselect all list box items in regular list box you should use _control lbSetCurSel -1; then to do the same for LB_MULTI list box, you should use lbSetSelected with appropriate changes. Share this post Link to post Share on other sites
Larrow 2822 Posted September 1, 2022 5 hours ago, Schatten said: I assumed that if to deselect all list box items in regular list box you should use _control lbSetCurSel -1; then to do the same for LB_MULTI list box 7 hours ago, Schatten said: _control lbSetSelected [-1, true]; No you have to specify each row individually. Quote Sets the selection state of the given row of the given listbox of style LB_MULTI. The command has to be called for every row which is needed to be selected for "_row" from 0 to lbSize _ctrl -1 do { _ctrl lbSetSelected[ _row, false ]; }; TBH it would be handy to have an alternate syntax for this command that excepts an array of rows to change. TICKET @killzone_kid Share this post Link to post Share on other sites