Page 1 of 1
Changing the order of the items in a scrolling list field
Posted: Fri Apr 16, 2021 2:42 pm
by radora
Hello community,
I am trying to create svg buttons which enable the user to change the order of the things in a scrolling list field.
It should work similarly to a music playlist where u can change the order of the songs that are to be played.
I have 4 buttons:
--- moveOneUp - (swap with the item above)
--- moveOneDown - (swap with the item underneath)
--- moveToFirst - (put the selected item all the way top)
--- moveToLast - (put the selected item all the way to the bottom)
In the attached img you can see it as well. I am able to get the data from the selected row, save it in a variable and read the one above or below the selected row but I still cant figure out how to swap them or to put the selected row as first/last.
Any tips/help would be much appreciated.
Best regards,
Radoslav
Re: Changing the order of the items in a scrolling list field
Posted: Fri Apr 16, 2021 4:17 pm
by richmond62
-
The scripts for the 4 possibilities are in the buttons.
Това е не много трудно, нали?
По принцип е само логика.
-
oneUp
Code: Select all
on mouseUp
put the selectedText of fld "fDATA" into MYLINE
put the selectedLine of fld "fDATA" into MYLINEnum
set the itemDelimiter to " "
put item 2 of MYLINEnum into MYnum
if MYnum > 1 then
put (MYnum - 1) into NEWnum
put line NEWnum of fld "fDATA" into SWOP
put MYLINE into line NEWnum of fld "fDATA"
put SWOP into line MYnum of fld "fDATA"
end if
end mouseUp
Re: Changing the order of the items in a scrolling list field
Posted: Sat Apr 17, 2021 5:46 am
by dunbarx
Here is a stack similar to one I wrote about 30 years ago to do something similar. You may find it a better method.
Simply click on any line in the field, hold and drag to a new line location and release. The original drops into that spot, and the other lines adjust to allow it.
Craig
It is a bit simplistic, since I just recreated it here from memory. But you can always add bells and whistles...
Re: Changing the order of the items in a scrolling list field
Posted: Sat Apr 17, 2021 11:54 am
by jmburnod
Thanks Craig for resuscitate old stuff
I just add a mouserelease on fld script to hide fld "traveler"
Code: Select all
on mouserelease
hide fld "traveler"
end mouserelease
Jean-Marc
Re: Changing the order of the items in a scrolling list field
Posted: Sun Apr 18, 2021 8:07 am
by radora
You are amazing guys, thank you so much!
I am really starting to like LiveCode
richmond62 :
Много благодаря, не мога да отговоря на личното съобщение понеже ми казва, че съм твърде нов юзър все още.
В Пловдив съм отраснал и аз иначе.
Appreciatively,
Radoslav
Re: Changing the order of the items in a scrolling list field
Posted: Sun Apr 18, 2021 3:27 pm
by dunbarx
Jean-Marc.
I just add a mouserelease on fld script to hide fld "traveler"
Very useful if the user strays from the field. Was that a bell or a whistle?
Craig
Re: Changing the order of the items in a scrolling list field
Posted: Sun Apr 18, 2021 3:51 pm
by dunbarx
Radoslav.
You will gain full privileges when you have, I think, seven posts.
Craig
Re: Changing the order of the items in a scrolling list field
Posted: Mon May 17, 2021 2:38 pm
by radora
And can you please give me some hints on how to accomplish the same behavior on a DataGrid?
I basically want to build a music playlist, where the user can reorder the songs and choose where to start.
The user selects items(songs) from a dropdown list and adds them to a playlist(scrolling list field) and it is also inserted into an "invisible" DataGrid, where I store more detailed information like filePaths etc., so I am trying to in other words synchronize them.
Cheers, Radoslav