avoid vscroll stops between two lines

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

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

avoid vscroll stops between two lines

Post by jmburnod » Sun Apr 18, 2021 4:24 pm

Hi All,
I search a safe way to avoid scroll stops between two lines.
Is there one somewhere ?
Best regards
Jean-Marc
https://alternatic.ch

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

Re: avoid vscroll stops between two lines

Post by dunbarx » Sun Apr 18, 2021 6:41 pm

Jean-Marc.

What are scroll stops? All my scrolling fields seem to scroll rather smoothly.

Craig

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

Re: avoid vscroll stops between two lines

Post by richmond62 » Sun Apr 18, 2021 6:48 pm

What are scroll stops?
Maybe the OP is referring to coded scrolling rather than manual scrolling.

SparkOut
Posts: 2843
Joined: Sun Sep 23, 2007 4:58 pm

Re: avoid vscroll stops between two lines

Post by SparkOut » Sun Apr 18, 2021 8:10 pm

Hmmm. I don't know, but I think there's no (simple) way, if I understand correctly. I imagine the OP wants to have the visible gap between visible lines of text neatly flush with top of the field (and bottom) so that no partial view of a half a line is displayed.
You could prevent different text styling, set a fixed lineHeight that exactly divides the field height, set matching scrollbarLineInc and scrollbarLineDec properties and check the scrollbarDrag message to get the position that the user scrolled to, round that to the right amount to match the fixed lineHeight and adjust the vScroll accordingly. Also probably needing to deal with the jerkiness of the interface that would introduce.

Just tried this quickly and it is a little bit jerky but works (if that is even what is wanted)

Code: Select all

on scrollbarDrag pThumb
   --assumes a fixed lineHeight of 16 for this field
   set the vScroll of me to trunc(pThumb / 16) * 16
end scrollbarDrag

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

Re: avoid vscroll stops between two lines

Post by dunbarx » Sun Apr 18, 2021 8:29 pm

Sparkout.

I am sure you are right about Jean-Marc's question, and your thoughts seem to be the right workaround. But as you mentioned, the scroll action would be "jerky" to the extent of the lineHeight. And if one were to insist on smooth scrolling, then there would have to be a jerk at the end when the scrolling stopped, so the lines would, er, align.

I think I will go play now, to see if that endmost jerkiness can be smoothed in its own little world...

But I

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

Re: avoid vscroll stops between two lines

Post by dunbarx » Sun Apr 18, 2021 8:57 pm

So I have run into this problem before. I do not believe any message is sent when one stops dragging the thumb in a scrolling field. "ScrollBarDrag" is sent constantly while dragging, being the "mouseMove" of the scrolling world, but I do not see how to know when one stops scrolling.

"mouseStillDown" also is sent from the scrollbar, but no other "standard" messages. I could check the scroll value between successive "mouseStillDowns", but that may not always be the point where the user actually ends the scroll.

If I knew when scrolling stops, that is, when the mouse was released, the task of realigning the field text smoothly and quickly, pixel-by-pixel until the nearest integral lineHeight sits perfectly within the field is simple.

So before I overlay another control on top of the scrollbar so I can get LC to talk to me, am I right about this? I seem to remember a thread on this very point a few years ago, and such an overlying control was the only way around the problem.

Craig

SparkOut
Posts: 2843
Joined: Sun Sep 23, 2007 4:58 pm

Re: avoid vscroll stops between two lines

Post by SparkOut » Sun Apr 18, 2021 9:11 pm

dunbarx wrote:
Sun Apr 18, 2021 8:57 pm
I do not believe any message is sent when one stops dragging the thumb in a scrolling field. "ScrollBarDrag" is sent constantly while dragging, being the "mouseMove" of the scrolling world, but I do not see how to know when one stops scrolling.
I don't believe there is a handy message to catch either - hence the quick and dirty, jerky scrollbarDrag handler.
I thought about sending a message for a a "scrollTidy" handler forward in time from the scrollbarDrag handler, which will delete any "scrollTidy" entries in the pending Messages before sending it, so there's only one handled, and only after a delay when the user is no longer actively dragging the scrollbar. (It doesn't mean the user hasn't just paused dragging while still holding the mouse down on the scrollbar though.)
But it seemed like a lot of effort for a "meh" benefit that I'm not even certain is what's desired.

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

Re: avoid vscroll stops between two lines

Post by jmburnod » Sun Apr 18, 2021 9:38 pm

Hi Both,
Thanks for help
Sparkout's script works fine for me.
That was about an other thread which needed a way to avoid the user stop scroll between two lines.
viewtopic.php?f=7&t=35736
Kind regards
Jean-Marc
https://alternatic.ch

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”