Page 1 of 2
Jumpy motion
Posted: Wed Jul 23, 2014 1:18 am
by Simon
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.
Thanks for any help,
Simon
Re: Jumpy motion
Posted: Wed Jul 23, 2014 1:31 am
by sefrojones
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
Re: Jumpy motion
Posted: Wed Jul 23, 2014 1:48 am
by Simon
Much better thanks!
Now if that flash could be solved, that would be even better.
Simon
Re: Jumpy motion
Posted: Wed Jul 23, 2014 2:13 am
by sefrojones
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
Re: Jumpy motion
Posted: Wed Jul 23, 2014 2:20 am
by Simon
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

Re: Jumpy motion
Posted: Wed Jul 23, 2014 2:33 am
by sefrojones
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!
--Sefro
Re: Jumpy motion
Posted: Wed Jul 23, 2014 9:18 am
by [-hh]
..........
Re: Jumpy motion
Posted: Wed Jul 23, 2014 10:50 am
by bn
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
Re: Jumpy motion
Posted: Wed Jul 23, 2014 11:45 am
by [-hh]
..........
Re: Jumpy motion
Posted: Wed Jul 23, 2014 1:15 pm
by bn
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
Re: Jumpy motion
Posted: Wed Jul 23, 2014 3:13 pm
by [-hh]
..........
Re: Jumpy motion
Posted: Wed Jul 23, 2014 5:03 pm
by bn
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
Re: Jumpy motion
Posted: Wed Jul 23, 2014 5:51 pm
by [-hh]
..........
Re: Jumpy motion
Posted: Wed Jul 23, 2014 7:28 pm
by bn
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
Re: Jumpy motion
Posted: Wed Jul 23, 2014 8:00 pm
by [-hh]
..........