1

これはopenlaszloのチャットアプリケーションです。inputtext領域に書き込みます。送信されたテキストをテキスト領域で受信します。しばらくすると、テキストフィールドにテキストが表示されなくなります。そこで、テキスト領域にスクロールバーを追加したいと思います。しかし、私はそれを機能させることができません。何か案は?前もって感謝します!!

<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>
4

1 に答える 1

2

OpenLaszloでスクロールバーを使用する方法を明確にするために、Red5/chat固有のコードを削除しました。スクロールする入力テキストには、高さを設定しないでください。親ビューはコンテンツをクリップする必要があり、入力テキストのサイズが親ビューよりも大きくなると、スクロールバーがアクティブになります。

<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の両方のランタイムでOpenLaszlo5.0(トランク)を使用してこのコードをテストしました。

于 2012-07-27T22:19:37.503 に答える