I thought I finally understood how to use a scroller, then this:
In the sample script below, if you use the 'Load text file' button and select a text file of moderate line size (about 80 characters), the text area of the window will be loaded with the lines from that file. Everything looks good. Then, if you operate the scroller to move down in the text area, and move the mouse pointer over the 'Load text file' button, the text on the button disappears. If you scroll back to the top and move the mouse pointer over the button, the text reappears. Down, disappears; up, reappears; reliably.
I used as a model the cookbook example of scrolling text, so I think I checked off the requirements: 1) as-is on the text style, 2) set the line-list, etc., etc. I isolated all that fussing in the LOAD-TEXT-DATA function so it all would be in one spot and I wouldn't forget anything. So I am a bit stumped and wonder if anyone can assist.
Thank you. Sample script follows. (I hope this is not a head-slapper.)
R E B O L [
Title: 'Show a funny situation with scrolling text'
]
TEXT-FILEID: none ;; Name of file we are fixing.
TEXT-DATA: copy [] ;; Data from the file, in lines.
TEXT-STRING: copy '' ;; Data from the file, as a sting for showing.
;; Called by LOAD-TEXT-FILE for the sake of modularity.
LOAD-TEXT-DATA: does [
MAIN-FILEDATA/text: TEXT-STRING
MAIN-FILEDATA/para/scroll/y: 0
MAIN-FILEDATA/line-list: none
MAIN-FILEDATA/user-data: second size-text MAIN-FILEDATA
MAIN-SCROLLER/data: 0
MAIN-SCROLLER/redrag MAIN-FILEDATA/size/y / MAIN-FILEDATA/user-data
show MAIN-FILEDATA
show MAIN-SCROLLER
]
LOAD-TEXT-FILE: does [
if not TEXT-FILEID: request-file/only [
alert 'No file specified.'
exit
]
;; We want the text file as lines so we can process one line at a time...
TEXT-DATA: copy []
TEXT-DATA: read/lines TEXT-FILEID
;; ...but it seems text must be a string to be put into a text style.
;; TEXT-STRING: read TEXT-FILEID ;; Alternative idea not used
TEXT-STRING: copy ''
foreach LINE TEXT-DATA [
append TEXT-STRING rejoin [LINE newline]
]
;; Put the string of text into the scrolling text style.
LOAD-TEXT-DATA
;; Display the name of the file we are working on.
MAIN-FILENAME/text: to-string TEXT-FILEID
MAIN-FILENAME/line-list: none
show MAIN-FILENAME
]
SCROLL-TEXT: does [
MAIN-FILEDATA/para/scroll/y: negate MAIN-SCROLLER/data *
(max 0 MAIN-FILEDATA/user-data - MAIN-FILEDATA/size/y)
show MAIN-FILEDATA
]
MAIN-WINDOW: layout [
across
banner 'Conditional Gangpunch'
return
MAIN-FILEDATA: text 800x600 as-is black white font-name font-fixed
MAIN-SCROLLER: scroller 20x600 [SCROLL-TEXT]
return
button 150 'Load text file' [LOAD-TEXT-FILE]
MAIN-FILENAME: info 500
]
view center-face main-window