Sie sind nicht angemeldet.

1

Donnerstag, 6. September 2012, 17:36

Problem with scrolling textfield and loading a new panorama

Hi,

On my tour I'm using a textfield plugin and I want the text to be scrollable so I used exactly the same code as show in the examples page:
http://krpano.com/examples/10815/example…gtextfield.html

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- the textfield with a scrollbar and scroll buttons -->
	<layer name="textbox" url="textfield.png" align="center" x="0" y="0" width="280" height="200">
		
		<layer name="textmask" type="container" align="lefttop" x="5" y="5" width="240" height="190" maskchildren="true">
			<layer name="text" url="%SWFPATH%/plugins/textfield.swf" handcursor="false" children="false" align="lefttop" x="10" y="10" width="220" autoheight="true" background="false" border="false" html="data:testtext" css="color:#000000; font-family:Arial; font-size:12;" />
		</layer>
		
		<layer name="scrollbar" type="container" bgcolor="0x000000" bgalpha="0.3" align="righttop" x="5" y="5" zorder="1" width="19" height="190" />
		
		<layer name="scrollup" url="dirbutton.png" align="righttop" x="24" y="5" zorder="2" rotate="-90" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19"
		       ondown="asyncloop(pressed, sub(ny,layer[text].y,10); add(ny,+8); sub(th,170,layer[text].pixelheight); if(ny GT 0, set(ny,0)); div(sy,ny,th); mul(sy,133); add(sy,24); copy(layer[scrollslider].y,sy); add(ny,10); copy(layer[text].y,ny); );"
		       />

		<layer name="scrolldown" url="dirbutton.png" align="rightbottom" x="24" y="5" zorder="2" rotate="+90" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19"
		       ondown="asyncloop(pressed, sub(ny,layer[text].y,10); add(ny,-8); sub(th,170,layer[text].pixelheight); if(ny LT th, copy(ny,th)); div(sy,ny,th); mul(sy,133); add(sy,24); copy(layer[scrollslider].y,sy); add(ny,10); copy(layer[text].y,ny); );"
		       />

		<layer name="scrollslider" url="sliderbutton.png" align="righttop" x="5" y="24" zorder="2" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" 
		       ondown="copy(cy,y);copy(sy,mouse.stagey);dragging();" 
		       dragging="if(pressed, sub(dy,mouse.stagey,sy); add(ny,cy,dy); if(ny LT 24, set(ny,24)); if(ny GT 157, set(ny,157)); copy(y,ny); sub(ty,ny,24); div(ty,133); sub(th,170,layer[text].pixelheight); mul(ty,th); add(ty,10); copy(layer[text].y,ty); delayedcall(0,dragging()); );"
		       />

	</layer>


When I change a panorama I also want the text in the textfield to change so in the new panorama's xml I set:

Quellcode

1
2
3
4
5
6
7
<action name="onxmlcompleteaction">
set(layer[text].html, 'data:newtext');
</action>

<data name="newtext">
		Lorem ipsum...
</data> 


The text changes fine, but if I scrolled the text before, then after loading the new panorama the new text doesn't show from the beggining and the scroll position doesn't 'reset' to the top.
How can i reset the scroll to the top after loading a new pano so the new text will be shown from the beggining and not somewhere in the middle?

This causes a big problem especially if the previous text was long and I scrolled it down to the end and the new text is, for example only one short sentence - then it doesn't show at all. it only resets to the top after pressing the scroll buttons...

2

Mittwoch, 12. September 2012, 09:23

Hi,
How can i reset the scroll to the top
the inner text element is just a normal <layer> element that will be moved (scrolled) by changing the y position,
to 'reset' it, just set the y position to its initial value (which is 10 in this case),
e.g.

Quellcode

1
set(layer[text].y,10);


best regards,
Klaus