Quantcast

Drag List Items Up and Down

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Drag List Items Up and Down

Richard Gaskin via use-livecode
There is a near universal behavior on mobile, varying flavors of color and style but the UX is almost the same everywhere whether it is your contacts, book marks in Safari, or songs on play lists in Spotify.

you have a list like this, after each item the common icon is often 2 horizontal bars,

apples       ==
oranges    ==
grapes       ==
kiwi           ==

the user can long press, hold down and drag up and down on the little bars on the right and move the list item up and down to re-order the list.

Before I go nuts in a deep dive building this from ground zero, does anyone have a library that does this already they can share?

Needs to work on mobile.

Mahalo!

BR
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

AndyP
Try this

Create a scrolling field

Add a few lines

In the field properties check the Lock text it will not work without this


Add this to the field

on mouseDown
   put word 2 of the clickLine into tcl
   set the textcolor of line tcl of me to "red"
   if line tcl of me is empty then
      exit mousedown
   end if
   put item 2 of the mouseLoc into tstarty
   put the effective textHeight of me into th
   repeat while the mouse is down
      if item 2 of the mouseLoc - tstarty > (th/2) then
         lock screen
         put cr & line tcl of me after line tcl + 1 of me
         delete line tcl of me
         add 1 to tcl
         set the textcolor of line tcl of me to "red"
         add th to tstarty
         unlock screen
      else if tstarty - item 2 of the mouseLoc > (th/2) then
         lock screen
         put line tcl of me & cr before line tcl - 1 of me
         delete line tcl + 1 of me
         subtract 1 from tcl
         set the textcolor of line tcl of me to "red"
         subtract th from tstarty
         unlock screen
      end if
   end repeat
   set the textcolor of line tcl of me to "black"
   set the hilitedLine of me to tcl
end mouseDown

This came from a question on one of the forums, not sure which and from whom.
Andy Piddock

My software never has bugs. It just develops random features.

TinyIDE a Free alternative minimalist IDE Plugin for LiveCode TinyIDE

Script editor Themer for LC http://2108.co.uk

PointandSee is a FREE simple but full featured under cursor colour picker / finder. http://www.pointandsee.co.uk - made with LiveCode

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
Very nice little script!

Question:  You can actually drag an item "up" and out of the field and it
disappears forever.  Any way to avoid this?

SKIP KIMPEL

On Thu, Feb 2, 2017 at 11:14 AM, AndyP via use-livecode <
[hidden email]> wrote:

> Try this
>
> Create a scrolling field
>
> Add a few lines
>
> In the field properties *check the Lock text* /it will not work without
> this/
>
>
> Add this to the field
>
> on mouseDown
>    put word 2 of the clickLine into tcl
>    set the textcolor of line tcl of me to "red"
>    if line tcl of me is empty then
>       exit mousedown
>    end if
>    put item 2 of the mouseLoc into tstarty
>    put the effective textHeight of me into th
>    repeat while the mouse is down
>       if item 2 of the mouseLoc - tstarty > (th/2) then
>          lock screen
>          put cr & line tcl of me after line tcl + 1 of me
>          delete line tcl of me
>          add 1 to tcl
>          set the textcolor of line tcl of me to "red"
>          add th to tstarty
>          unlock screen
>       else if tstarty - item 2 of the mouseLoc > (th/2) then
>          lock screen
>          put line tcl of me & cr before line tcl - 1 of me
>          delete line tcl + 1 of me
>          subtract 1 from tcl
>          set the textcolor of line tcl of me to "red"
>          subtract th from tstarty
>          unlock screen
>       end if
>    end repeat
>    set the textcolor of line tcl of me to "black"
>    set the hilitedLine of me to tcl
> end mouseDown
>
> This came from a question on one of the forums, not sure which and from
> whom.
>
>
>
>
> -----
> Andy Piddock
>
>
> My software never has bugs. It just develops random features.
>
> TinyIDE a Free alternative minimalist IDE Plugin for LiveCode
> TinyIDE
>
>
> Script editor Themer for LC http://2108.co.uk
>
> PointandSee is a FREE simple but full featured under cursor colour picker
> / finder.
> http://www.pointandsee.co.uk  - made with LiveCode
> --
> View this message in context: http://runtime-revolution.
> 278305.n4.nabble.com/Drag-List-Items-Up-and-Down-tp4712158p4712163.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

AndyP
In reply to this post by Richard Gaskin via use-livecode
Modified script
added  

if within (field "myField", the mouseLoc) is true then

on mouseDown
   
   put word 2 of the clickLine into tcl
   set the textcolor of line tcl of me to "red"
   if line tcl of me is empty then
      exit mousedown
   end if
   put item 2 of the mouseLoc into tstarty
   put the effective textHeight of me into th
   repeat while the mouse is down
      if item 2 of the mouseLoc - tstarty > (th/2) then
         if within (field "myField", the mouseLoc) is true then
            lock screen
            put cr & line tcl of me after line tcl + 1 of me
            delete line tcl of me
            add 1 to tcl
            set the textcolor of line tcl of me to "red"
            add th to tstarty
            unlock screen
         end if
      else if tstarty - item 2 of the mouseLoc > (th/2) then
         if within (field "myField", the mouseLoc) is true then
            lock screen
            put line tcl of me & cr before line tcl - 1 of me
            delete line tcl + 1 of me
            subtract 1 from tcl
            set the textcolor of line tcl of me to "red"
            subtract th from tstarty
            unlock screen
         end if
      end if
         end repeat
   set the textcolor of line tcl of me to "black"
   set the hilitedLine of me to tcl
   
end mouseDown
Andy Piddock

My software never has bugs. It just develops random features.

TinyIDE a Free alternative minimalist IDE Plugin for LiveCode TinyIDE

Script editor Themer for LC http://2108.co.uk

PointandSee is a FREE simple but full featured under cursor colour picker / finder. http://www.pointandsee.co.uk - made with LiveCode

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
Excellent... works like a charm.  Thanks for sharing!

SKIP

On Thu, Feb 2, 2017 at 1:48 PM, AndyP via use-livecode <
[hidden email]> wrote:

> Modified script
> added
>
> /if within (field "myField", the mouseLoc) is true then /
>
> on mouseDown
>
>    put word 2 of the clickLine into tcl
>    set the textcolor of line tcl of me to "red"
>    if line tcl of me is empty then
>       exit mousedown
>    end if
>    put item 2 of the mouseLoc into tstarty
>    put the effective textHeight of me into th
>    repeat while the mouse is down
>       if item 2 of the mouseLoc - tstarty > (th/2) then
>          if within (field "myField", the mouseLoc) is true then
>             lock screen
>             put cr & line tcl of me after line tcl + 1 of me
>             delete line tcl of me
>             add 1 to tcl
>             set the textcolor of line tcl of me to "red"
>             add th to tstarty
>             unlock screen
>          end if
>       else if tstarty - item 2 of the mouseLoc > (th/2) then
>          if within (field "myField", the mouseLoc) is true then
>             lock screen
>             put line tcl of me & cr before line tcl - 1 of me
>             delete line tcl + 1 of me
>             subtract 1 from tcl
>             set the textcolor of line tcl of me to "red"
>             subtract th from tstarty
>             unlock screen
>          end if
>       end if
>          end repeat
>    set the textcolor of line tcl of me to "black"
>    set the hilitedLine of me to tcl
>
> end mouseDown
>
>
>
> -----
> Andy Piddock
>
>
> My software never has bugs. It just develops random features.
>
> TinyIDE a Free alternative minimalist IDE Plugin for LiveCode
> TinyIDE
>
>
> Script editor Themer for LC http://2108.co.uk
>
> PointandSee is a FREE simple but full featured under cursor colour picker
> / finder.
> http://www.pointandsee.co.uk  - made with LiveCode
> --
> View this message in context: http://runtime-revolution.
> 278305.n4.nabble.com/Drag-List-Items-Up-and-Down-tp4712158p4712166.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
Scott Rossi published "Get In Line”, a different sort of solution which involves dragging an img representation of the text line. I liked the added opportunity for visual effect that this method offered. I have used it successfully in several applications including ones in iOS. Scott talks about this stack here:

<http://lists.runrev.com/pipermail/use-livecode//2005-January/049411.html>

You can find a working copy that is open for examination by:

1—>  go url "http://www.tactilemedia.com/tmpanel.rev”

2—>  scroll to the “DEMOS” channel  (wait for them to load… there is a bunch of great stuff here!)

3—>  scroll down to "Get In Line” and click


Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web       http://elementarysoftware.com/
email     [hidden email]
office     1-800-615-0867
------------------------------------------------------


> On Feb 2, 2017, at 10:56 AM, Skip Kimpel via use-livecode <[hidden email]> wrote:
>
> Excellent... works like a charm.  Thanks for sharing!
>
> SKIP
>
> On Thu, Feb 2, 2017 at 1:48 PM, AndyP via use-livecode <
> [hidden email]> wrote:
>
>> Modified script
>> added
>>
>> /if within (field "myField", the mouseLoc) is true then /
>>
>> on mouseDown
>>
>>   put word 2 of the clickLine into tcl
>>   set the textcolor of line tcl of me to "red"
>>   if line tcl of me is empty then
>>      exit mousedown
>>   end if
>>   put item 2 of the mouseLoc into tstarty
>>   put the effective textHeight of me into th
>>   repeat while the mouse is down
>>      if item 2 of the mouseLoc - tstarty > (th/2) then
>>         if within (field "myField", the mouseLoc) is true then
>>            lock screen
>>            put cr & line tcl of me after line tcl + 1 of me
>>            delete line tcl of me
>>            add 1 to tcl
>>            set the textcolor of line tcl of me to "red"
>>            add th to tstarty
>>            unlock screen
>>         end if
>>      else if tstarty - item 2 of the mouseLoc > (th/2) then
>>         if within (field "myField", the mouseLoc) is true then
>>            lock screen
>>            put line tcl of me & cr before line tcl - 1 of me
>>            delete line tcl + 1 of me
>>            subtract 1 from tcl
>>            set the textcolor of line tcl of me to "red"
>>            subtract th from tstarty
>>            unlock screen
>>         end if
>>      end if
>>         end repeat
>>   set the textcolor of line tcl of me to "black"
>>   set the hilitedLine of me to tcl
>>
>> end mouseDown
>>
>>
>>
>> -----
>> Andy Piddock
>>
>>
>> My software never has bugs. It just develops random features.
>>
>> TinyIDE a Free alternative minimalist IDE Plugin for LiveCode
>> TinyIDE
>>
>>
>> Script editor Themer for LC http://2108.co.uk
>>
>> PointandSee is a FREE simple but full featured under cursor colour picker
>> / finder.
>> http://www.pointandsee.co.uk  - made with LiveCode
>> --
>> View this message in context: http://runtime-revolution.
>> 278305.n4.nabble.com/Drag-List-Items-Up-and-Down-tp4712158p4712166.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode







_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
In reply to this post by AndyP
Excellent, Andy! Thanks for sharing this.

The only minor, cosmetic change I made was on the next to last line:

    set the textColor of line tcl of me to empty

My hilite color was set to a dark blue, and the black on dark blue was hard to read. Setting it back to empty means that it will go to a contrasting white when highlighted.

Devin


On Feb 2, 2017, at 11:48 AM, AndyP via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Modified script
added

/if within (field "myField", the mouseLoc) is true then /

on mouseDown

  put word 2 of the clickLine into tcl
  set the textcolor of line tcl of me to "red"
  if line tcl of me is empty then
     exit mousedown
  end if
  put item 2 of the mouseLoc into tstarty
  put the effective textHeight of me into th
  repeat while the mouse is down
     if item 2 of the mouseLoc - tstarty > (th/2) then
        if within (field "myField", the mouseLoc) is true then
           lock screen
           put cr & line tcl of me after line tcl + 1 of me
           delete line tcl of me
           add 1 to tcl
           set the textcolor of line tcl of me to "red"
           add th to tstarty
           unlock screen
        end if
     else if tstarty - item 2 of the mouseLoc > (th/2) then
        if within (field "myField", the mouseLoc) is true then
           lock screen
           put line tcl of me & cr before line tcl - 1 of me
           delete line tcl + 1 of me
           subtract 1 from tcl
           set the textcolor of line tcl of me to "red"
           subtract th from tstarty
           unlock screen
        end if
     end if
        end repeat
  set the textcolor of line tcl of me to "black"
  set the hilitedLine of me to tcl

end mouseDown



-----
Andy Piddock


My software never has bugs. It just develops random features.

TinyIDE a Free alternative minimalist IDE Plugin for LiveCode
TinyIDE


Script editor Themer for LC http://2108.co.uk

PointandSee is a FREE simple but full featured under cursor colour picker / finder.
http://www.pointandsee.co.uk  - made with LiveCode
--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Drag-List-Items-Up-and-Down-tp4712158p4712166.html
Sent from the Revolution - User mailing list archive at Nabble.com<http://Nabble.com>.

_______________________________________________
use-livecode mailing list
[hidden email]<mailto:[hidden email]>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
This modification honours the minimum and maximum drag line to avoid the
inadvertent insertion of empty lines, and cosmetically works for both list
and standard fields...


-- Field script
on mouseDown
  put the num of lines of me into tmax # Store drag constraint
  put word 2 of the clickLine into tcl
  if not the listBehavior of me then set the textcolor of line tcl of me to
"red" # Cosmetic
  if line tcl of me is empty then
    exit mousedown
  end if
  put item 2 of the mouseLoc into tstarty
  put the effective textHeight of me into th
  repeat while the mouse is down
    if item 2 of the mouseLoc - tstarty > (th/2) then
      if within (me, the mouseLoc) is true then
        lock screen
        if tcl<tmax then # Constrain drag to max lines
          put cr & line tcl of me after line (tcl + 1) of me
          delete line tcl of me
          add 1 to tcl
          if not the listBehavior of me then set the textcolor of line tcl
of me to "red" # Cosmetic
          add th to tstarty
        end if
        if the listBehavior of me then set the hilitedLine of me to tcl #
Update hilitedline
        unlock screen
      end if
    else if tstarty - item 2 of the mouseLoc > (th/2) then
      if within (me, the mouseLoc) is true then
        lock screen
        put line tcl of me & cr before line (tcl - 1) of me
        delete line tcl + 1 of me
        subtract 1 from tcl
        if tcl<1 then put 1 into tcl # Constrain drag to min lines
        if not the listBehavior of me then set the textcolor of line tcl of
me to "red" # Cosmetic
        subtract th from tstarty
         if the listBehavior of me then set the hilitedLine of me to tcl #
Update hilitedline
        unlock screen
      end if
    end if
  end repeat
  if not the listBehavior of me then set the textcolor of line tcl of me to
empty # Cosmetic
end mouseDown

Hugh Senior
FLCo

> On Feb 2, 2017, at 11:48 AM, AndyP via use-livecode <use-
> [hidden email]<mailto:[hidden email]>> wrote:
>
> Modified script
> added
>
> /if within (field "myField", the mouseLoc) is true then /
>
> on mouseDown
>
>   put word 2 of the clickLine into tcl
>   set the textcolor of line tcl of me to "red"
>   if line tcl of me is empty then
>      exit mousedown
>   end if
>   put item 2 of the mouseLoc into tstarty
>   put the effective textHeight of me into th
>   repeat while the mouse is down
>      if item 2 of the mouseLoc - tstarty > (th/2) then
>         if within (field "myField", the mouseLoc) is true then
>            lock screen
>            put cr & line tcl of me after line tcl + 1 of me
>            delete line tcl of me
>            add 1 to tcl
>            set the textcolor of line tcl of me to "red"
>            add th to tstarty
>            unlock screen
>         end if
>      else if tstarty - item 2 of the mouseLoc > (th/2) then
>         if within (field "myField", the mouseLoc) is true then
>            lock screen
>            put line tcl of me & cr before line tcl - 1 of me
>            delete line tcl + 1 of me
>            subtract 1 from tcl
>            set the textcolor of line tcl of me to "red"
>            subtract th from tstarty
>            unlock screen
>         end if
>      end if
>         end repeat
>   set the textcolor of line tcl of me to "black"
>   set the hilitedLine of me to tcl
>
> end mouseDown
>
>
>
> -----
> Andy Piddock


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

AndyP
Nice addition .. thanks.
Andy Piddock

My software never has bugs. It just develops random features.

TinyIDE a Free alternative minimalist IDE Plugin for LiveCode TinyIDE

Script editor Themer for LC http://2108.co.uk

PointandSee is a FREE simple but full featured under cursor colour picker / finder. http://www.pointandsee.co.uk - made with LiveCode

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
Thank you all!  

FYI tmpanel.rev crashes 8.1.3 (at least here on Sierra)

 

On 2/4/17, 11:23 AM, "use-livecode on behalf of AndyP via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    Nice addition .. thanks.
   
   
   
    -----
    Andy Piddock

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drag List Items Up and Down

Richard Gaskin via use-livecode
 tmPanel did crash once but eventually ran for me on Sierra using LC 8.1.2

Scott Morrow

> On Feb 6, 2017, at 11:47 AM, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> Thank you all!  
>
> FYI tmpanel.rev crashes 8.1.3 (at least here on Sierra)
>
>
>
> On 2/4/17, 11:23 AM, "use-livecode on behalf of AndyP via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:
>
>    Nice addition .. thanks.
>
>
>
>    -----
>    Andy Piddock
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...