Hi,
i inserted a scrolling filed in a card field. This scrolling field contains a big amount of text. I want to get a notification, if the user scrolled to the bottom of the text.
I wrote a event handler on scrollbarEnd and placed this handler inside the scrolling field, but this handler is never called. I think, this event is handled by the scrollbar and so it's never forewarded to the parent (the scrolling field).
I cant't find a solution for this problem.
Is there anybody with an idea?
Scrolling Field: How to detect scrollEnd?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 52
- Joined: Sun Jan 20, 2008 7:06 am
Here You Go
Razorblade,
I'm not exactly sure if this is what you are looking for, but there is a way that i know of to where you can handle it inside an "on scrollBarDrag" handler and within that handler, you can check to see how far they may have scrolled. It is the "vScroll" or "hScroll" function. Now as an example, you could call the "vScroll" function "on scollBarDrag" and if the "vScroll" reaches a certain number, then put something inside a variable, and/or activate a "next" button or an "accept" button or whatever it is that you want. There are many ways to go about doing this.
Example:
--Here is script for field scollbar checking--put script in field--
on scrollBarDrag
if the vScroll of me is xx then
enable btn "accept" -- or whatever else you would like to do
end if
end scrollBarDrag
--Here is a script if you would like the frield to be scrolled to the end before they continue--
Global tVar
on scrollBarDrag
put the vScroll into tVar -- puts it into the var "tVar"
if the vScroll of me is xx then
enable btn "accept" -- or whatever else you would like to do
end if
end scrollBarDrag
--the above script does the same thing at first, it still enables the button, or doeswhatever it is told to do--
--then, to check from a button on the event of clicking it--
on mouseUp -- for button
if the vScroll of fld "field_name" is xx then
-put command here--
end if
end mouseUp
--you could even check the "tVar" variable if it is set as global, and if it has a certain value, then you could allow the user to continue or whatever it is that you want them to be able to do--
-Christopher
I'm not exactly sure if this is what you are looking for, but there is a way that i know of to where you can handle it inside an "on scrollBarDrag" handler and within that handler, you can check to see how far they may have scrolled. It is the "vScroll" or "hScroll" function. Now as an example, you could call the "vScroll" function "on scollBarDrag" and if the "vScroll" reaches a certain number, then put something inside a variable, and/or activate a "next" button or an "accept" button or whatever it is that you want. There are many ways to go about doing this.
Example:
--Here is script for field scollbar checking--put script in field--
on scrollBarDrag
if the vScroll of me is xx then
enable btn "accept" -- or whatever else you would like to do
end if
end scrollBarDrag
--Here is a script if you would like the frield to be scrolled to the end before they continue--
Global tVar
on scrollBarDrag
put the vScroll into tVar -- puts it into the var "tVar"
if the vScroll of me is xx then
enable btn "accept" -- or whatever else you would like to do
end if
end scrollBarDrag
--the above script does the same thing at first, it still enables the button, or doeswhatever it is told to do--
--then, to check from a button on the event of clicking it--
on mouseUp -- for button
if the vScroll of fld "field_name" is xx then
-put command here--
end if
end mouseUp
--you could even check the "tVar" variable if it is set as global, and if it has a certain value, then you could allow the user to continue or whatever it is that you want them to be able to do--
-Christopher
Hi Razorblade,
The maximum scroll equals:
provided that the margins are an integer and the fixedLineHeight of the field is true. If the margins are no integer, you probably need to use item 4 of the margins. If the fixedLineHeight is not true, you need to find a way to figure out the height of the last line of your field. Also, the dontWrap of your field has to be set to true.
This is a nice way to do it:
(untested, but should work)
Now, if you have this script at stack level or in a library, you can call this property using:
The first line should return an integer, the second should set the scroll of a field to the largest possible value.
Best,
Mark
The maximum scroll equals:
Code: Select all
the formattedHeight of fld x - the height of fld x - the margins of fld x - the textHeight of fld x
This is a nice way to do it:
Code: Select all
getProp maxScroll
if word 1 of the name of the target is "field" then
return (the formattedHeight of the target - the height of the target - the margins of the target - the textHeight of the target)
else return empty
end maxScroll
Now, if you have this script at stack level or in a library, you can call this property using:
Code: Select all
put the maxScroll of fld x
set the vScroll of fld x to the maxScroll of fld x
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode