Changing the order of the items in a scrolling list field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
radora
Posts: 3
Joined: Fri Feb 26, 2021 10:09 am

Changing the order of the items in a scrolling list field

Post by radora » Fri Apr 16, 2021 2:42 pm

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
Attachments
Untitled.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Changing the order of the items in a scrolling list field

Post by richmond62 » Fri Apr 16, 2021 4:17 pm

SShot 2021-04-16 at 18.13.49.png
-
The scripts for the 4 possibilities are in the buttons.

Това е не много трудно, нали?

По принцип е само логика. 8)
-
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
Attachments
SWAP SHOP.livecode.zip
(1.53 KiB) Downloaded 120 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Changing the order of the items in a scrolling list field

Post by dunbarx » Sat Apr 17, 2021 5:46 am

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
dragRelocate.livecode.zip
(1.48 KiB) Downloaded 133 times
It is a bit simplistic, since I just recreated it here from memory. But you can always add bells and whistles...

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Changing the order of the items in a scrolling list field

Post by jmburnod » Sat Apr 17, 2021 11:54 am

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
https://alternatic.ch

radora
Posts: 3
Joined: Fri Feb 26, 2021 10:09 am

Re: Changing the order of the items in a scrolling list field

Post by radora » Sun Apr 18, 2021 8:07 am

You are amazing guys, thank you so much!
I am really starting to like LiveCode :)


richmond62 :
Много благодаря, не мога да отговоря на личното съобщение понеже ми казва, че съм твърде нов юзър все още.
В Пловдив съм отраснал и аз иначе.



Appreciatively,
Radoslav

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Changing the order of the items in a scrolling list field

Post by dunbarx » Sun Apr 18, 2021 3:27 pm

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? :wink:

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Changing the order of the items in a scrolling list field

Post by dunbarx » Sun Apr 18, 2021 3:51 pm

Radoslav.

You will gain full privileges when you have, I think, seven posts.

Craig

radora
Posts: 3
Joined: Fri Feb 26, 2021 10:09 am

Re: Changing the order of the items in a scrolling list field

Post by radora » Mon May 17, 2021 2:38 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”