[Modules] ListEx (all OS / DPI)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

nicoh wrote:Could you fix this?
Yes

Bugfix: Select rows
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
nicoh
User
User
Posts: 26
Joined: Thu Sep 19, 2019 10:44 am

Re: [Modules] ListEx (all OS / DPI)

Post by nicoh »

Hi,

thanks for fixing!

I'm sorry, but there is one more bug:

Code: Select all

OpenWindow(0, 100, 100, 300, 220, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListEx::Gadget(0, 5, 5, 290, 190, "Test", 50, "", ListEx::#GridLines|ListEx::#MultiSelect, 0)

ListEx::AddItem(0, ListEx::#LastItem, "Line 1")
ListEx::AddItem(0, ListEx::#LastItem, "Line 2")
ListEx::AddItem(0, ListEx::#LastItem, "Line 3")
ListEx::AddItem(0, ListEx::#LastItem, "Line 4")
ListEx::AddItem(0, ListEx::#LastItem, "Line 5")

CreatePopupMenu(0)
MenuItem(0, "Debug selected lines")

Define.i Event, Index, Count

Repeat
  Event = WaitWindowEvent()
 
  Select Event
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_RightClick
              DisplayPopupMenu(0, WindowID(0))
          EndSelect
      EndSelect
     
    Case #PB_Event_Menu
      Select EventMenu()
        Case 0
          Debug "Selected Lines:"
          Count = ListEx::CountItems(0) - 1
          For Index = 0 To Count
            If ListEx::GetItemState(0, Index) & ListEx::#Selected
              Debug ListEx::GetItemText(0, Index, 0)
            EndIf
          Next
      EndSelect
     
  EndSelect
 
Until Event = #PB_Event_CloseWindow
When you select items with a right click, the selection flags does not update.

Reproduce with the code above (example):
1. Select "Line 4" with a simple left click
2. Right click "Line 3" and click the popup menu
3. Debugger output will be "Selected Lines: Line 4"

Would be nice if you could fix that.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

No problem. Some errors can only be found when using the module
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
nicoh
User
User
Posts: 26
Joined: Thu Sep 19, 2019 10:44 am

Re: [Modules] ListEx (all OS / DPI)

Post by nicoh »

Hi,

your bugfix ended up in a new bug:

When you select more than one row and right click in the gadget, the selection is resetted and only the right clicked row is selected. This isn't a useful behaivor, because I need to open a context menu on right click which depends on the selected rows.

Code: Select all

OpenWindow(0, 100, 100, 300, 220, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListEx::Gadget(0, 5, 5, 290, 190, "Test", 50, "", ListEx::#GridLines|ListEx::#MultiSelect, 0)

ListEx::AddItem(0, ListEx::#LastItem, "Line 1")
ListEx::AddItem(0, ListEx::#LastItem, "Line 2")
ListEx::AddItem(0, ListEx::#LastItem, "Line 3")
ListEx::AddItem(0, ListEx::#LastItem, "Line 4")
ListEx::AddItem(0, ListEx::#LastItem, "Line 5")

CreatePopupMenu(0)
MenuItem(0, "Dummy menu")

Define.i Event

Repeat
  Event = WaitWindowEvent()
 
  Select Event
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_RightClick
              DisplayPopupMenu(0, WindowID(0))
          EndSelect
      EndSelect
     
  EndSelect
 
Until Event = #PB_Event_CloseWindow


How to reproduce:
1. Select Line 1 to 3 with multiselect
2. Right click Line 3 to open the popup menu
3. Only Line 3 will be selected (but Line 1 and 2 should still be selected)
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Update
I got a little confused about the selection.
The right mouse click doesn't select anything anymore, but only opens the popup menu.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
nicoh
User
User
Posts: 26
Joined: Thu Sep 19, 2019 10:44 am

Re: [Modules] ListEx (all OS / DPI)

Post by nicoh »

Thorsten1867 wrote: The right mouse click doesn't select anything anymore, but only opens the popup menu.
That's better than before but I think it's still not the best solution.
Now you need two clicks to open the context menu: Left click to select the item and right click to open the menu.
I think that's not very user friendly.

In my opinion, the best solution would be to let it work like the ListIconGadget() from PureBasic.

Code: Select all

If OpenWindow(0, 100, 100, 300, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ListIconGadget(0, 5, 5, 290, 190, "Test", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_MultiSelect)
   For i = 1 To 5 : AddGadgetItem(0, i, "Line " + Str(i)) : Next   
   Repeat
     Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
 EndIf
First, select a few rows with left click.
Now, there are two possibilities what can happen on a right click:
1. If you right click an item which is already selected, nothing changes.
2. If you right click an item which is not selected, this item will be selected and nothing else.

Just try the code above and you'll see it. I think that would be the best solution.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Now it should work like the ListIconGadget:
  • Shift / Ctrl + RightClick => popup menu only
  • RightClick => reset selection / change focus / popup menu
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
nicoh
User
User
Posts: 26
Joined: Thu Sep 19, 2019 10:44 am

Re: [Modules] ListEx (all OS / DPI)

Post by nicoh »

Thorsten1867 wrote:Now it should work like the ListIconGadget:
  • Shift / Ctrl + RightClick => popup menu only
  • RightClick => reset selection / change focus / popup menu
Confirmed, works very well now.

Thanks for your updates and bugfixes! :)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: [Modules] ListEx (all OS / DPI)

Post by davido »

@Thorsten1867,
I have chanced upon what appears to be a small bug:
ComboBox does not seem to work correctly on my MacBook.
Clicking the 'down-arrow' displays the choices in a drop-down menu. On attempting to choose one of those choices, the menu disappears!

I checked the same code on a Windows 10 system and it performs correctly.
DE AA EB
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: [Modules] ListEx (all OS / DPI)

Post by Everything »

Just update it from repo and sort feature doesn't work anymore...
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Update:
  • Bugs fixed
  • Constants for autoresize adapted to other gadgets
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: [Modules] ListEx (all OS / DPI)

Post by Everything »

Thorsten1867 wrote:Update:
  • Bugs fixed
  • Constants for autoresize adapted to other gadgets
Where to get the updated code?
Hoeppner1867/PureBasic/ListEx/
ListExModule.pbi | Update ListExModule.pbi | 6 days ago
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Try it again
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: [Modules] ListEx (all OS / DPI)

Post by Everything »

Thorsten1867 wrote:Try it again
Yes, now sorting is works again. Thx.
There is another bug - try to edit empty cell, leave it empty and click somewhere on window to finish.
Line 3393 SelectElement(): SelectElement(): negative index error.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Update: Unfortunately I can't reproduce the error, but I added a query.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Post Reply