home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Encyklopedia Omnia
/
Planeta.iso
/
data
/
m_info.dir
/
00012_Script_FieldThumbScroll
< prev
next >
Wrap
Text File
|
2000-10-16
|
4KB
|
112 lines
---------------------------------------
-- HTML ScrollThumb --
-- --
-- Behavior per scrollare un field --
-- Html tramite un cursore. --
-- Applicalo al cursore. --
---------------------------------------
property normalCursor, pressedCursor, upArrowSN, downArrowSN,¼
spaceFromArrows, thumbMinY, thumbMaxY, thumbX, thumbName, NStesto
on beginSprite
set the cursor of sprite (the currentSpriteNum) to¼
[member normalCursor, member (normalCursor & "_m")]
resetThumbScroll
end
on resetThumbScroll
-- chiamato da beginSprite e ogniqualvolta
-- cambi il testo nel field.
set upDisplace = getAt(the regPoint of member the member of sprite the currentSpriteNum,2)
set downDisplace = (the height of sprite the currentSpriteNum) - upDisplace
set thumbMinY = (the bottom of sprite upArrowSN) + upDisplace + spaceFromArrows
set thumbMaxY = (the top of sprite downArrowSN) - downDisplace - spaceFromArrows
set thumbX = the locH of sprite the currentSpriteNum
set the loc of sprite the currentSpriteNum to point(thumbX,thumbMinY)
end
on mouseDown
if (the height of member the member of sprite NStesto) > (the PageHeight of member the member of sprite NStesto) then
-- settings iniziali
set ns = the currentSpriteNum
set the cursor of sprite (ns) to¼
[member pressedCursor, member (pressedCursor & "_m")]
set totalTextHeight = the height of member the member of sprite NStesto
set singlePageHeight = the PageHeight of member the member of sprite NStesto
set scrollExtent = thumbMaxY - thumbMinY
set oldY = the locV of sprite ns
set offset = getAt(the clickLoc, 2) - the locV of sprite ns
-- loop sul mouseDown
repeat while the mousedown
set newY = mouseV() - offset
if newY > thumbMaxY then set newY = thumbMaxY
if newY < thumbMinY then set newY = thumbMinY
-- se necessario...
if newY <> oldY then
-- sposta il thumb
set the loc of sprite ns to point(thumbX, newY)
set oldY = newY
-- e scrolla il testo
set newScrollTop = (totalTextHeight - singlePageHeight) * ((newY - thumbMinY)/float(scrollExtent))
set the scrollTop of member the member of sprite NStesto to newScrollTop
end if
updateStage
end repeat
set the cursor of sprite (ns) to¼
[member normalCursor, member (normalCursor & "_m")]
end if
end
on trackArrowScroll
-- chiamato dalle freccie per seguire lo scroll
set totalTextHeight = the height of member the member of sprite NStesto
set singlePageHeight = the PageHeight of member the member of sprite NStesto
set scrollExtent = thumbMaxY - thumbMinY
set currentScrollTop = the scrollTop of member the member of sprite NStesto
set diff = totalTextHeight - singlePageHeight
if diff <> 0 then
set newY = thumbMinY + scrollExtent*(currentScrollTop/float(diff))
-- sposta il thumb
set the loc of sprite the currentSpriteNum to point(thumbX, newY)
end if
end
on getPropertyDescriptionList
set p_list = [#upArrowSN: [#comment:"N╛ sprite freccia s∙:",¼
#format: #integer, #default: 1, #range: [#min:1,#max:120]],¼
#downArrowSN: [#comment:"N╛ sprite freccia gi∙:",¼
#format: #integer, #default: 1, #range: [#min:1,#max:120]],¼
#normalCursor:[#comment:"Cursore normale:",¼
#format: #string, #default: "palmo"],¼
#pressedCursor:[#comment:"Cursore premuto:",¼
#format: #string, #default: "pugno"],¼
#spaceFromArrows: [#comment:"Spaziatura tra freccie e thumb:",¼
#format: #integer, #default: 2],¼
#thumbName:[#comment:"Nome del membro html:",¼
#format: #string, #default: "testo"],¼
#NStesto:[#comment:"N╛ sprite del testo:",¼
#format: #integer, #default: 1, #range: [#min:1,#max:120]]]
return p_list
end
on getBehaviorDescription
set descr = "Behavior per scrollare un field Html tramite un cursore."
set descr = descr & RETURN & "Applicalo al cursore."
return descr
end