ExplorerListGadget with "unwanted memory"

Just starting out? Need help? Post your questions and find answers here.
Kraut
New User
New User
Posts: 5
Joined: Thu Sep 29, 2022 6:50 am

ExplorerListGadget with "unwanted memory"

Post by Kraut »

Hi everybody!

stumpled upon a feature in ExplorerListGadget which I want to get rid of. In the example I added I can select some dir entries on the left gadget. When clicking the right gadget selecting entries and return to the left gadget, it still keeps the selections. Is there a way to clean the selections without re-reading the directory? For example via event like "Case #PB_EventType_Focus" (which doesn't work with this gadget) ?

Code: Select all

   If OpenWindow(0, 0, 0, 800, 600, "ExplorerListGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ExplorerListGadget(0, 0, 0, 400, 600, GetUserDirectory(#PB_Directory_Documents)+"*.*", #PB_Explorer_MultiSelect)
    ExplorerListGadget(1, 401, 0, 400, 600, GetUserDirectory(#PB_Directory_Documents)+"*.*", #PB_Explorer_MultiSelect)
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5014
Joined: Sun Apr 12, 2009 6:27 am

Re: ExplorerListGadget with "unwanted memory"

Post by RASHAD »

Hi

Code: Select all

If OpenWindow(0, 0, 0, 800, 600, "ExplorerListGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ExplorerListGadget(0, 0, 0, 400, 600, GetUserDirectory(#PB_Directory_Documents)+"*.*", #PB_Explorer_MultiSelect)
    ExplorerListGadget(1, 401, 0, 400, 600, GetUserDirectory(#PB_Directory_Documents)+"*.*", #PB_Explorer_MultiSelect)
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Quit = 1
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 0
              SetGadgetText(1,GetUserDirectory(#PB_Directory_Documents)+"*.*")  
            Case 1
              SetGadgetText(0,GetUserDirectory(#PB_Directory_Documents)+"*.*")
          EndSelect
      EndSelect
    Until Quit = 1
  EndIf
Egypt my love
Kraut
New User
New User
Posts: 5
Joined: Thu Sep 29, 2022 6:50 am

Re: ExplorerListGadget with "unwanted memory"

Post by Kraut »

Hi RASHAD;

thanks for your post. Do I understand it right that there is no other way than re-reading the directory?
User avatar
mk-soft
Always Here
Always Here
Posts: 6431
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ExplorerListGadget with "unwanted memory"

Post by mk-soft »

Only Windows ...

Code: Select all

Enumeration CustomTypeEvent #PB_EventType_FirstCustomValue
  #MyEventTypeFocus
  #MyEventTypeLostFocus
EndEnumeration

Procedure DoGadgetEventFocus()
  Static gadget, lastgadget = -1
  
  gadget = GetActiveGadget()
  If gadget <> lastgadget
    If lastgadget >= 0
      PostEvent(#PB_Event_Gadget, GetActiveWindow(), lastgadget, #MyEventTypeLostFocus)
    EndIf
    If gadget >= 0
      PostEvent(#PB_Event_Gadget, GetActiveWindow(), gadget, #MyEventTypeFocus)
      lastgadget = gadget
    Else
      lastgadget = -1
    EndIf
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, "ExplorerListGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ExplorerListGadget(0, 0, 0, 400, 600, GetUserDirectory(#PB_Directory_Documents)+"*.*", #PB_Explorer_MultiSelect)
    ExplorerListGadget(1, 401, 0, 400, 600, GetUserDirectory(#PB_Directory_Documents)+"*.*", #PB_Explorer_MultiSelect)
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Quit = 1
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 0
              Select EventType()
                Case #MyEventTypeFocus
                  Debug "Focus Gadget 0"
                Case #MyEventTypeLostFocus
                  Debug "LostFocus Gadget 0"
                  SendMessage_(GadgetID(0), #LVM_SETSELECTIONMARK, 0, -1)
                  
              EndSelect
              ; SetGadgetText(1,GetUserDirectory(#PB_Directory_Documents)+"*.*")  
            Case 1
              Select EventType()
                Case #MyEventTypeFocus
                  Debug "Focus Gadget 1"
                Case #MyEventTypeLostFocus
                  Debug "LostFocus Gadget 1"
                  SendMessage_(GadgetID(0), #LVM_SETSELECTIONMARK, 0, -1)
                  
              EndSelect
              ; SetGadgetText(0,GetUserDirectory(#PB_Directory_Documents)+"*.*")
              
          EndSelect
      EndSelect
      DoGadgetEventFocus()
    Until Quit = 1
  EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: ExplorerListGadget with "unwanted memory"

Post by freak »

SetGadgetItemState() can be used to set or clear the selection state of each item. So something like this will clear all the selections (cross platform):

Code: Select all

For i = 0 To CountGadgetItems(0)-1
  SetGadgetItemState(0, i, 0) ; Absence of #PB_Explorer_Selected flag clears the selection if there is any
Next i
quidquid Latine dictum sit altum videtur
Post Reply