Page 11 of 33

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

Posted: Thu Sep 19, 2019 3:29 pm
by Thorsten1867
nicoh wrote:Could you fix this?
Yes

Bugfix: Select rows

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

Posted: Fri Sep 20, 2019 7:55 am
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.

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

Posted: Fri Sep 20, 2019 2:54 pm
by Thorsten1867
No problem. Some errors can only be found when using the module

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

Posted: Mon Sep 23, 2019 8:14 am
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)

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

Posted: Mon Sep 23, 2019 12:03 pm
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.

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

Posted: Tue Sep 24, 2019 7:45 am
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.

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

Posted: Tue Sep 24, 2019 12:28 pm
by Thorsten1867
Now it should work like the ListIconGadget:
  • Shift / Ctrl + RightClick => popup menu only
  • RightClick => reset selection / change focus / popup menu

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

Posted: Tue Sep 24, 2019 12:39 pm
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! :)

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

Posted: Sun Sep 29, 2019 6:58 pm
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.

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

Posted: Tue Oct 01, 2019 8:22 am
by Everything
Just update it from repo and sort feature doesn't work anymore...

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

Posted: Tue Oct 01, 2019 12:44 pm
by Thorsten1867
Update:
  • Bugs fixed
  • Constants for autoresize adapted to other gadgets

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

Posted: Tue Oct 01, 2019 1:51 pm
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

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

Posted: Tue Oct 01, 2019 4:41 pm
by Thorsten1867
Try it again

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

Posted: Tue Oct 01, 2019 5:54 pm
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.

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

Posted: Wed Oct 02, 2019 3:07 pm
by Thorsten1867
Update: Unfortunately I can't reproduce the error, but I added a query.