SetGadgetState() seems not to work with ExplorerListGadget()
SetGadgetState() is also not listed in ExplorerListGadget() part of the manual.
SetGadgetState not implemented for ExplorerListGadget?
ExplorerListGadget:
GetGadgetState(): Get the first selected item (-1 if none selected).
Guess what SetGadgetState() would do
SetGadgetState would be very important after i.e. the ExplorerList being updated, so that the selection can remain the same.
i.e: after a file/folder has been deleted or removed.
(esp. as the ExplorerList automaticaly refreshes if a folder is updated).
GetGadgetState(): Get the first selected item (-1 if none selected).
Guess what SetGadgetState() would do

SetGadgetState would be very important after i.e. the ExplorerList being updated, so that the selection can remain the same.
i.e: after a file/folder has been deleted or removed.
(esp. as the ExplorerList automaticaly refreshes if a folder is updated).
Re: SetGadgetState not implemented for ExplorerListGadget?
Wow! So old wish and no one had wished it again!
I have three ExplorerList boxes – two of them are disabled and are for indicating purposes only. If I select file from one enabled listbox, then two others are showing corresponding file – if they exist. If not, then disabled listboxes items must be deselected. For that reason SetGadgetState() is must be for ExplorerListGadget. I have implemented this feature now by Windows API, but this means, that it’s not crossportable.
I have three ExplorerList boxes – two of them are disabled and are for indicating purposes only. If I select file from one enabled listbox, then two others are showing corresponding file – if they exist. If not, then disabled listboxes items must be deselected. For that reason SetGadgetState() is must be for ExplorerListGadget. I have implemented this feature now by Windows API, but this means, that it’s not crossportable.

Re: SetGadgetState not implemented for ExplorerListGadget?
You may use the following cross-platform procedure SelectExplorerListRow() which uses the appropriate API functions of MacOS, Linux and Windows to select a row in an ExplorerListGadget:MuuSer wrote:I have implemented this feature now by Windows API, but this means, that it’s not crossportable.
Code: Select all
EnableExplicit
Procedure SelectExplorerListRow(ExplorerListID.I, RowIndex.I)
If RowIndex < CountGadgetItems(ExplorerListID)
SetActiveGadget(ExplorerListID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
Protected TreePath.I = gtk_tree_path_new_from_indices_(RowIndex, -1)
gtk_tree_view_set_cursor_(GadgetID(ExplorerListID), TreePath, 0, #False)
CompilerCase #PB_OS_MacOS
Protected IndexSet.I
IndexSet = CocoaMessage(0, CocoaMessage(0, 0, "NSIndexSet alloc"),
"initWithIndex:", RowIndex)
CocoaMessage(0, GadgetID(ExplorerListID),
"selectRowIndexes:", IndexSet,
"byExtendingSelection:", #NO)
CocoaMessage(0, IndexSet, "release")
CompilerCase #PB_OS_Windows
Protected Item.LVITEM
Item\mask = #LVIF_STATE
Item\state = #LVIS_SELECTED
Item\stateMask = #LVIS_SELECTED
SendMessage_(GadgetID(ExplorerListID), #LVM_SETITEMSTATE, RowIndex, @Item)
CompilerEndSelect
EndIf
EndProcedure
OpenWindow(0, 270, 100, 400, 200, "ExplorerListGadget")
; ---- Attention: The flag #PB_Explorer_AlwaysShowSelection is necessary to
; see a selected entry in Windows OS
ExplorerListGadget(0, 10, 10, 380, 180, "/", #PB_Explorer_AlwaysShowSelection)
SelectExplorerListRow(0, 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: SetGadgetState not implemented for ExplorerListGadget?
Sorry, it's much easier because PB has a native command to select and unselect a row in an ExplorerListGadget, so there is no need to use platform-specific API functions:
Use State = #PB_Explorer_Selected to select a row
and State = 0 to unselect a row (this is currently only documented for the ListViewGadget, but seems to work even cross-plattform for the ExplorerListGadget as demonstrated in this example)
Code: Select all
SetGadgetItemState(#Gadget, Item, State)
and State = 0 to unselect a row (this is currently only documented for the ListViewGadget, but seems to work even cross-plattform for the ExplorerListGadget as demonstrated in this example)