Page 1 of 1
ExplorerListGadget with "unwanted memory"
Posted: Sat Sep 02, 2023 8:31 pm
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
Re: ExplorerListGadget with "unwanted memory"
Posted: Sat Sep 02, 2023 10:54 pm
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
Re: ExplorerListGadget with "unwanted memory"
Posted: Sun Sep 03, 2023 10:23 am
by Kraut
Hi RASHAD;
thanks for your post. Do I understand it right that there is no other way than re-reading the directory?
Re: ExplorerListGadget with "unwanted memory"
Posted: Sun Sep 03, 2023 11:16 am
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
Re: ExplorerListGadget with "unwanted memory"
Posted: Sun Sep 03, 2023 10:49 pm
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