Jumpy motion

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Jumpy motion

Post by Simon » Wed Jul 23, 2014 1:18 am

Hi All,
With the stack attached I can't seem to figure out a way to smooth out the motion.
The deal is when you select a line of text, a red dot image moves (actually has it's loc set) from one selected line to another. I'm see a big delay in even hiding the dot.
delayed.zip
LC 6.6.1
(1.6 KiB) Downloaded 224 times
Thanks for any help,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Jumpy motion

Post by sefrojones » Wed Jul 23, 2014 1:31 am

Simon,

Changing the second "selectionchanged" handler to a "mousedown" handler seems to do the job. Does that work for you?

--Sefro

edit: just changing the handler was a little buggy, but this seems to work well:

Code: Select all

on mousedown
    hide img "delete"
   lock screen
end mousedown


on mouseup
      put (the top of the target +5) into tTop
   put the effective textHeight of the target into tTextHeight
   
   put the selectedLine of the target into tMult
   put word 2 of tMult into tMult
   put (tTop + (tTextHeight * tMult)) into tPos
   set the bottom of img "delete" to tPos
   show img "delete"
   unlock screen
end mouseup

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Jumpy motion

Post by Simon » Wed Jul 23, 2014 1:48 am

Much better thanks!
Now if that flash could be solved, that would be even better.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Jumpy motion

Post by sefrojones » Wed Jul 23, 2014 2:13 am

There may be a much better way to do this, but this is what I came up with :

Code: Select all

on mousedown
send "mouseup" to me
end mousedown

on mousemove
   if the mouse is down then
      send "mouseup" to me
      end if
end mousemove

on mouseup
   
     put (the top of the target +5) into tTop
   put the effective textHeight of the target into tTextHeight
   
   put the selectedLine of the target into tMult
   put word 2 of tMult into tMult
   put (tTop + (tTextHeight * tMult)) into tPos
   set the bottom of img "delete" to tPos
 
end mouseup
How's that look?

--Sefro

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Jumpy motion

Post by Simon » Wed Jul 23, 2014 2:20 am

Excellent!
Thanks.

Now keep your fingers crossed it actually works where I'm using it.

Simon
Edit: hmmm... took out the mouseMove and didn't seem to make a difference.. but it's cool because this is for mobile :)
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Jumpy motion

Post by sefrojones » Wed Jul 23, 2014 2:33 am

Simon wrote:hmmm... took out the mouseMove and didn't seem to make a difference.. but it's cool because this is for mobile :)
Yeah, I added that because I noticed on desktop when you hold the mouse down and try to scroll through the list it was glitchy, the mousemove handler cleared that up for desktop anyway. Glad it's working for ya! :D

--Sefro

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Jumpy motion

Post by [-hh] » Wed Jul 23, 2014 9:18 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:42 pm, edited 1 time in total.
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Jumpy motion

Post by bn » Wed Jul 23, 2014 10:50 am

Hi Simon,

how about

Code: Select all

on mouseDown
   set the top of img "delete" to (the formattedTop of the clickline) - 1
end mouseDown
BTW before selectionChanged only works in behaviors as all the before and after commands.

Kind regards
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Jumpy motion

Post by [-hh] » Wed Jul 23, 2014 11:45 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:42 pm, edited 1 time in total.
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Jumpy motion

Post by bn » Wed Jul 23, 2014 1:15 pm

Hi Hermann,

ok, here is the speed-test.

It takes virtually the same amount of milliseconds whether you use formattedTop or selectedLoc.

And the time is entirely determined by the screen refresh. The calculation is below 1 millisecond for both. (You can see this if you put a "lock screen" at the top of the mouseDown handler and no unlock screen within the handler and let Livecode do the screen refresh)

The test is done on some 1300 lines with variable textHeight as per your suggestion.
Click into the field to see timing for formattedTop, click with the option-key down to see selectedLoc.

And please note when scrolling what happens to the red dot. It took me years to hack that :)

Kind regards
Bernd
Attachments
speedTestformattedTop.livecode.zip
(7.47 KiB) Downloaded 215 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Jumpy motion

Post by [-hh] » Wed Jul 23, 2014 3:13 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:42 pm, edited 1 time in total.
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Jumpy motion

Post by bn » Wed Jul 23, 2014 5:03 pm

Hi Hermann and all,

here is a version that uses formattedRect to calculate the center of the line and places the image there. This is at the cost of a simple one-liner.

Additionally to the scrollbar arrowKeys are also taken care of. (tricky,tricky to sync them with the changing selection and image)
MouseMove also implemented.

I did not implement Hermann's new version.

Kind regards
Bernd
Attachments
speedTestformattedTop_2.livecode.zip
(7.69 KiB) Downloaded 226 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Jumpy motion

Post by [-hh] » Wed Jul 23, 2014 5:51 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:43 pm, edited 1 time in total.
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Jumpy motion

Post by bn » Wed Jul 23, 2014 7:28 pm

Hi Hermann,

here is the ping:

Actually what you are doing with rawKeyDown is the same I am doing with the arrowkey. You and I intercept the trigger and manually select the next or previous line and set the location of the image within the same lock screen. So I don't understand why intercepting arrowKey is too late but intercepting rawkey is not. It is both the same. We both work around the fact that arrowkey triggers a message from the operating system, a message which can not be enclosed in a lockscreen i.e. the change of location of the red dot is signifiantly delayed in case of a passed arrowkey or rawkey.

Kind regards
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Jumpy motion

Post by [-hh] » Wed Jul 23, 2014 8:00 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:43 pm, edited 1 time in total.
shiftLock happens

Post Reply