Page 1 of 1

[Done] SetGadgetStateEx() for ListView/Icon/Gadget()

Posted: Tue Sep 04, 2018 12:40 pm
by Peter
Hello,

until it is fixed, you can use SetGadgetStateEx() to scroll automatically to the selected Item for ListViewGadget() and ListIconGadget():

Code: Select all
EnableExplicit

Procedure SetGadgetStateEx(Gadget, SelectedItem)
 
  Select GadgetType(Gadget)
     
    Case #PB_GadgetType_ListView, #PB_GadgetType_ListIcon
     
      ! setTimeout( function() {
     
      SetGadgetState(Gadget, SelectedItem)
     
      ! if (($(spider_GadgetID(v_gadget).div).find(".dgrid-selected")).length > 0) {
      !   spider_GadgetID(v_gadget).gadget.scrollTo({x:0,y:$(spider_GadgetID(v_gadget).div).find(".dgrid-selected").position().top});
      ! } else {
      !   spider_GadgetID(v_gadget).gadget.scrollTo({x:0,y:0});
      ! }
     
      ! }, 10);
     
    Default
     
      Debug "Unsupported Gadget"
     
  EndSelect
 
EndProcedure

Enumeration
  #Window
  #ListViewGadget
  #ListIconGadget
EndEnumeration

Define Counter

OpenWindow(#Window, 0, 0, 510, 140, "ScrollIntoView", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

; ######################
; # ListViewGadget
; ######################

ListViewGadget(#ListViewGadget, 10, 10, 250, 120)

For Counter = 1 To 12
  AddGadgetItem (#ListViewGadget, -1, "Line " + Str(Counter) + " of the ListViewGadget")
Next

SetGadgetStateEx(#ListViewGadget, 10)

; ######################
; # ListIconGadget
; ######################

ListIconGadget(#ListIconGadget, 260, 10, 250, 120, "First Column", 200)

For Counter = 1 To 12
  AddGadgetItem (#ListIconGadget, -1, "Line " + Str(Counter) + " of the ListIconGadget")
Next

SetGadgetStateEx(#ListIconGadget, 10)


Greetings ... Peter

Re: SetGadgetStateEx() for ListViewGadget() and ListIconGadg

Posted: Tue Sep 04, 2018 1:49 pm
by Dirk Geppert
Thank you Peter!

Re: SetGadgetStateEx() for ListViewGadget() and ListIconGadg

Posted: Fri Nov 15, 2019 1:42 pm
by Fred
Already fixed in current version.