Page 2 of 2

Re: Gadget scrolling down

Posted: Sat Jan 04, 2020 9:40 am
by morosh
I tried Peter'example with a ListIcon, it didn't works, no scrolling with buttons, may be I'm missing something:

Code: Select all

EnableExplicit

Enumeration
  #myWindow
  #cmdScrollDown
  #cmdScrollUp
  #myListIconGadget
EndEnumeration

Procedure EditorScrollDown()
 
  Protected Selector = GadgetID(#myListIconGadget)
  ! $(v_selector.gadget.textbox).animate( { scrollTop: $(v_selector.gadget.textbox).prop("scrollHeight")}, 500); // with animation
  ! // v_selector.gadget.textbox.scrollTop = v_selector.gadget.textbox.scrollHeight; // without animation
 
EndProcedure

Procedure EditorScrollUp()
 
  Protected Selector = GadgetID(#myListIconGadget)
  ! $(v_selector.gadget.textbox).animate( { scrollTop: 0}, 500); // with animation
  ! // v_selector.gadget.textbox.scrollTop = 0; // without animation
 
EndProcedure


OpenWindow(#myWindow, #PB_Ignore, #PB_Ignore, 500, 500, "", #PB_Window_ScreenCentered)

ButtonGadget(#cmdScrollDown, 10, 10, 220, 30, "Scroll down")
ButtonGadget(#cmdScrollUp, 240, 10, 220, 30, "Scroll up")

ListIconGadget(#myListIconGadget, 10, 50, 480, 440,"No",50)

Define Counter

For Counter = 0 To 99
  AddGadgetItem(#myListIconGadget,-1, Str(Counter))
Next


BindGadgetEvent(#cmdScrollDown, @EditorScrollDown())
BindGadgetEvent(#cmdScrollUp, @EditorScrollUp())

any help is appreciated
Thanks

Re: Gadget scrolling down

Posted: Sat Jan 04, 2020 11:51 am
by Peter

Code: Select all

Procedure ListIconGadgetScrollDown()
  SetGadgetState(#myListIconGadget, CountGadgetItems(#myListIconGadget) - 1)
EndProcedure

Procedure ListIconGadgetScrollUp()
  SetGadgetState(#myListIconGadget, 0)
EndProcedure
(like in PureBasic)

Unfortunately ListIconGadgetScrollDown() does not work because of a bug in SpiderBasic.

Greetings ... Peter

Re: Gadget scrolling down

Posted: Thu Feb 18, 2021 10:33 pm
by Kurzer
morosh wrote:I tried Peter'example with a ListIcon, it didn't works, no scrolling with buttons, may be I'm missing something:
Hi Morosh,
try this if you want to scroll without select an ListIcon entry.

Code: Select all

EnableExplicit

Procedure Test()
	Protected selector = GadgetID(0)
  ! $(v_selector.div).find("div.dgrid-scroller").scrollTop(500);
EndProcedure

Define sLine.s, i.i

If OpenWindow(0, 0, 0, 330, 330, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ListIconGadget(0, 5, 30, 300, 150, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
   ListIconGadget(1, 5, 155, 300, 150, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
   ButtonGadget(2, 10,5, 300, 25, "Scroll ListIcon #0")
   
   For i = 1 To 70
   	AddGadgetItem(0, -1, "This is line " + Str(i) + ".")
   	AddGadgetItem(1, -1, "This is line " + Str(i) + ".")
   Next i
   
   BindGadgetEvent(2, @Test())
EndIf
Greetings
Markus

Re: Gadget scrolling down

Posted: Wed Oct 20, 2021 8:06 am
by hoerbie
Thanks to Kurzer for the tip with scrollTop for scrolling down.

It worked well, when the ListIconGadget was fully populated before, like in the above example when clicking the button.

But I had the problem, that it didn't work when opening a new window with the ListIconGadget, filling it with AddGadgetItem and then directly wanted to show the bottom of the list. (But maybe some other tweaks from the forum like deleting the header line and coloring some lines killed it.)

At the moment after opening the new window and filling the gadget I'm using one additional javascript line for starting the scrollTop after a short timeout:

Code: Select all

Procedure ScrollListDown(gdgid)
  Protected gid = GadgetID(gdgid)
  ! $(v_gid.div).find("div.dgrid-scroller").scrollTop(10000);
EndProcedure

OpenWindow(...)
ListIconGadget(...)
For (...)
  AddGadgetItem(...)
Next (...)

! setTimeout(f_scrolllistdown, 100, v_idofmylisticongadget);
If there is a better way, please post it ;-)

Greetings from hoerbie