2012-07-20 68 views
1

這是openlaszlo中的一個聊天應用程序。我在輸入文字區寫入。並在文本區域接收發送的文本。過了一段時間,我無法看到文本字段中的文本。所以,我想在文本區域添加一個滾動條。但我不能讓它工作。有任何想法嗎?提前致謝!!無法在文本字段中添加滾動條

<canvas height="100%" width="100%" bgcolor="white" allowfullscreen="true" debug="true"> 

<class name="chatSender"> 
<attribute name="_netConnection" /> 
<attribute name="_sharedObject" /> 

<handler name="oninit"> 
this._netConnection = new NetConnection(); 
this._netConnection.connect("rtmp://115.187.37.167/oflaDemo/room1"); 

this._sharedObject = SharedObject.getRemote("chat", this._netConnection.uri, true); 
this._sharedObject.connect(this._netConnection); 
Debug.write("ChatSender initiated"); 
</handler> 

<method name="sendMessage" args="mensaje"> 
Debug.write("SendMessage: " + mensaje) 
this._sharedObject.send("messageHandler",mensaje); 
</method> 
</class> 

<class name="chatReceiver"> 
<attribute name="_netConnection" /> 
<attribute name="_sharedObject" /> 

<handler name="oninit"><![CDATA[ 

this._netConnection = new NetConnection(); 
this._netConnection.connect("rtmp://115.187.37.167/oflaDemo/room1"); 


this._sharedObject = SharedObject.getRemote("chat", this._netConnection.uri, true); 
this._sharedObject.connect(this._netConnection); 


this._sharedObject.messageHandler = function(str) { 

var textoAnterior = texto.text; 
Debug.write(textoAnterior + "<br/>" + str); 
texto.setAttribute("text", textoAnterior + "<br/>" + str); 
}; 
Debug.write ("chatReceiver initiated"); 
]]> 
</handler> 
</class> 

<chatReceiver name="chatRec"/> 
<chatSender name="chatSen"/> 

<simplelayout/> 
<view width="100%" height="80%" bgcolor="white" clip="true"> 
<text id="texto" width="100%" height="90%" multiline="true" clip="true"> 
</text> 
</view> 

<view bgcolor="blue" width="70%"> 
<simplelayout axis="x"/> 
<inputtext bgcolor="cyan" width="100%" id="mensajeAEnviar"/> 
<button width="50" onclick="canvas.chatRec._cajaChat=texto; canvas.enviarTexto(mensajeAEnviar.text);">Send</button> 
</view> 

<method name="enviarTexto" args="texto"> 
Debug.write("enviarTexto:" + mensajeAEnviar.text); 
canvas.chatSen.sendMessage(mensajeAEnviar.text); 
mensajeAEnviar.setAttribute("text",""); 
</method> 

</canvas> 
+0

如果我的回答解決了問題,我建議您接受答案。 – 2012-08-17 12:22:59

+0

感謝您的幫助。我病了。所以我看不到你的迴應。抱歉耽擱了。再次感謝.. – Pallab 2012-08-20 10:09:43

+0

沒問題,我只是試圖保持Stackoverflow上的OpenLaszlo討論活躍,因爲OpenLaszlo論壇已經變成了一個悲傷的地方,與我們幾年前的活動相比。如果你有其他OpenLaszlo相關的問題,將來會有更多的人來幫助你解決Stackoverflow問題。 – 2012-08-20 10:57:31

回答

2

我已經刪除了的Red5 /聊天特定的代碼,使之清楚,你如何使用OpenLaszlo中的滾動條。對於要滾動的輸入文本,請勿設置高度。父視圖必須剪裁內容,然後當輸入文本的大小比父視圖大時,滾動條會激活。

<canvas height="100%" width="100%" bgcolor="white" allowfullscreen="true" debug="true"> 

    <method name="addLineOfText" args="line"><![CDATA[ 
     var newText = texto.text; 
     if (newText != '') 
      newText += '<br/>'; 
     newText += line; 
     texto.setAttribute("text", newText); 
    ]]> 
    </method> 

    <simplelayout/> 
    <view width="200" height="150" bgcolor="#eeffee" clip="true"> 
     <text id="texto" width="100%" multiline="true" clip="true"> 
      Here are just a few lines of text for testing...<br/> 
      Here are just a few lines of text for testing...<br/> 
      Here are just a few lines of text for testing...<br/> 
      Here are just a few lines of text for testing...<br/> 
      Here are just a few lines of text for testing... 
     </text> 
     <scrollbar axis="y" /> 
    </view> 

    <view bgcolor="blue" width="300"> 
     <simplelayout axis="x"/> 
     <inputtext id="mensajeAEnviar" 
        bgcolor="cyan" 
        width="100%" /> 
     <button id="but1" 
       width="50" 
       onclick="canvas.addLineOfText(mensajeAEnviar.text)" 
       text="Send" /> 
    </view> 
> 

</canvas> 

這裏是一個博客帖子在OpenLaszlo的滾動條上的詳細信息: http://www.antunkarlovac.com/blog/2006/11/16/using-a-scrollbar/

我已經在這兩個SWF10和DHTML運行測試此代碼用OpenLaszlo 5.0(主幹)。