Gadget scrolling down

Just starting out? Need help? Post your questions and find answers here.
morosh
Posts: 27
Joined: Mon Feb 02, 2015 7:48 pm

Re: Gadget scrolling down

Post 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
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Gadget scrolling down

Post 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
User avatar
Kurzer
Posts: 90
Joined: Mon May 26, 2014 9:33 am

Re: Gadget scrolling down

Post 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
SB 2.32 x86, Browser: Iron Portable V. 88.0.4500.0 (Chromium based), User age in 2023: 55y
"Happiness is a pet." | "Never run a changing system!"
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Gadget scrolling down

Post 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
Post Reply