When selecting a list item, ensure it is visible

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

When selecting a list item, ensure it is visible

Post by SparrowhawkMMU »

Hi,

Currently, if you use SetGadgetState() to select an item in a list box that is not currently visible (ie further up or down in the list so not in the visible view of the list gadget), it is not scrolled into view

Could this be changed so that even if the row is not visible, it is made visible (brought into focus) when selected programatically

Thanks
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: When selecting a list item, ensure it is visible

Post by Fred »

Could you post a small snippet ?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: When selecting a list item, ensure it is visible

Post by Peter »

Fred wrote:Could you post a small snippet ?
http://forums.spiderbasic.com/viewtopic ... 1251#p1251

(also for ListViewGadget())

Greetings ... Peter
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: When selecting a list item, ensure it is visible

Post by SparrowhawkMMU »

What he said ;)

Seriously though, if you need more from me, let me know.
User avatar
Paul
Posts: 195
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: When selecting a list item, ensure it is visible

Post by Paul »

Any progress on this request?

It's really annoying using AddGadgetItem() on a big list and the ListIconGadget resets itself to the beginning every time.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: When selecting a list item, ensure it is visible

Post by Peter »

obviously my code I'm referring to above has been deleted. :|

For this reason here once again:

Code: Select all

If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListViewGadget(0, 10, 10, 250, 120)
  For a = 1 To 12
    AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
  Next
  SetGadgetState(0, 10)
EndIf
User avatar
Paul
Posts: 195
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: When selecting a list item, ensure it is visible

Post by Paul »

Hi Peter,
Your code demonstrated the problem. The item is highlighted but is not in view. You have to scroll down to see the highlighted item.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: When selecting a list item, ensure it is visible

Post by Peter »

Paul wrote:Your code demonstrated the problem.
Yeah, that was the plan. ;)

Fred wanted to have a code snippet and now he has it (again).
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: When selecting a list item, ensure it is visible

Post by Dirk Geppert »

Is there already a solution? Maybe a workaround?

Strangely enough, it works within a larger web project. Unfortunately, I can't reproduce what's the reason it works. :?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: When selecting a list item, ensure it is visible

Post by Peter »

Dirk Geppert wrote:Maybe a workaround?

Code: Select all

Procedure ScrollIntoView(Gadget)
  ! 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})
  ! }
EndProcedure

If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListViewGadget(0, 10, 10, 250, 120)
  For a = 1 To 12
    AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
  Next
  
  SetGadgetState(0, 10)
  ScrollIntoView(0)
  
EndIf
Post Reply