Page 1 of 1
[SOLVED] Cannot select explorer item
Posted: Tue Mar 31, 2015 6:02 am
by SkyManager
I cannot figure out why I cannot select the explorer item.
Could anybody help?
Code: Select all
If Not OpenWindow(0, 100, 100, 500, 300, "Test", #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_SystemMenu)
End
EndIf
ExplorerListGadget(1, 0, 0, 200, 200, "", #PB_Explorer_AlwaysShowSelection | #PB_Explorer_FullRowSelect | #PB_Explorer_AutoSort | #PB_Explorer_MultiSelect)
SetGadgetItemState(1, 1, #PB_ListIcon_Selected) ; <-- PROBLEM
While #True
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow
End
EndIf
Wend
Re: Cannot select explorer item
Posted: Tue Mar 31, 2015 6:45 am
by Danilo
Use #PB_Explorer_Selected - it's a mistake in the documentation for SetGadgetItemState().
Code: Select all
If Not OpenWindow(0, 100, 100, 500, 300, "Test", #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_SystemMenu)
End
EndIf
ExplorerListGadget(1, 0, 0, 400, 200, "", #PB_Explorer_AlwaysShowSelection | #PB_Explorer_FullRowSelect | #PB_Explorer_AutoSort | #PB_Explorer_MultiSelect)
SetGadgetItemState(1, 1, #PB_Explorer_Selected) ; <-- PROBLEM solved
SetActiveGadget(1)
While #True
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow
End
EndIf
Wend
Re: Cannot select explorer item
Posted: Tue Mar 31, 2015 8:19 am
by SkyManager
Thanks a lot,
a follow-up question.
How to DE-select an item?
The documentaion only tells us how to select an item.
Re: Cannot select explorer item
Posted: Tue Mar 31, 2015 10:04 am
by Danilo
Undocumented, but seems to work (on Windows):
Code: Select all
#PB_Explorer_Deselected = 0
SetGadgetItemState(1, 1, #PB_Explorer_Selected) ; Select
SetGadgetItemState(1, 1, #PB_Explorer_Deselected) ; De-Select
SetGadgetItemState(1, -1, #PB_Explorer_Selected) ; Select All
SetGadgetItemState(1, -1, #PB_Explorer_Deselected) ; Clear Selection
Re: Cannot select explorer item
Posted: Tue Mar 31, 2015 10:34 am
by Shardik
Danilo wrote:Undocumented, but seems to work (on Windows):
That's right, it's only documented for the ListViewGadget but it seems indeed to work cross-platform for the ExplorerListGadget. The following example code was successfully tested on
- MacOS X 10.6.8 (Snow Leopard)
- Ubuntu 14.04 x64 with KDE
- Windows 7 x64 SP1
Code: Select all
OpenWindow(0, 100, 100, 420, 310, "Test")
ButtonGadget(0, 150, 280, 120, 25, "Unselect row 1")
ExplorerListGadget(1, 10, 10, 400, 260, "/",
#PB_Explorer_FullRowSelect | #PB_Explorer_MultiSelect)
SetGadgetItemState(1, 1, #PB_Explorer_Selected)
SetActiveGadget(1)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0
SetGadgetItemState(1, 1, 0)
EndIf
EndSelect
ForEver
Re: Cannot select explorer item
Posted: Tue Mar 31, 2015 11:49 am
by SkyManager
Thanks for the answer
My little experiment is as follow :
Code: Select all
state = GetGadgetItemState(#DirExplorer, k)
If state & #PB_Explorer_File
SetGadgetItemState(#DirExplorer, k, #PB_Explorer_File)
ElseIf state & #PB_Explorer_Directory
SetGadgetItemState(#DirExplorer, k, #PB_Explorer_Directory)
EndIf
That seems to work also