[Laszlo-user] Multi line edittext with scrollbar

gaurav gp at pagux.com
Sun Mar 11 04:52:22 PDT 2007


Hi Benjamin,
I went ahead and downloaded Stable openLazlo release and STILL IT DOESNT
WORK  :-(
All I want is scroll bar to automatically move down as more text is added
programmatically (its an protype chat application)
I have written with 4 versions of code what could have been a simple text
area component functionality other frameworks seems to easily provide .

I am sending all version of my code ...Can you giuys make it  Work ??
What i intend to do is simple  (prototype) ....
Anything user writes in edittext (userMsg) is displayed in another read
only  component  (chatMsg) AND Scrollbar should move down if extra text is
added ...its really frustrating I have wasted so much time such a simple
....I have to show a protype  on monday to client  get approval for building
application on  laszlo platform !!
Version 4
<canvas width="700" debug="true" >

  <window title="Alabot Answers" x="10" y="10"
          width="220" height="260" >
<view width="220" height="260" />

<view name="main" x="10" y="20" width="175" height="140" clip="true">
    <view name="contents">
      <text multiline="true" id="chatMsg">

      </text>
    </view>
 <scrollbar/>
   </view>
    <edittext x="10" y="175" width="175"  doesenter="true"  id="userMsg"  >
<method name="doEnterDown">
 Debug.write('Nice day if it do not rain'+userMsg.getText());
           chatMsg.setText(chatMsg.getText()+" \n "+userMsg.getText());
userMsg.setText ("");
           </method>
</edittext>
  </window>

 </canvas>
version 1

<canvas width="700" debug="true" >

  <window title="SImple Chat Client " x="10" y="10"
          width="220" height="260" >
<view width="220" height="260" />


    <edittext x="10" y="20" width="175" height="140" enabled="false"
id="chatMsg" >
 <scrollbar/>
</edittext>
    <edittext x="10" y="175" width="175"  doesenter="true"  id="userMsg"  >
<method name="doEnterDown">
 Debug.write('Nice day if it do not rain'+userMsg.getText());
           chatMsg.setText(chatMsg.getText()+" \n "+userMsg.getText());
userMsg.setText("");
           </method>
</edittext>
  </window>

 </canvas>



version 2

<canvas width="700" debug="true" >

  <window title="SImple Chat Client" x="10" y="10"
          width="220" height="260" >
<view width="220" height="260" />

<view name="main" x="10" y="20" width="175" height="140" clip="true">
    <view name="contents">
      <text multiline="true" id="chatMsg">

      </text>
    </view>
 <scrollbar/>
   </view>
    <edittext x="10" y="175" width="175"  doesenter="true"  id="userMsg"  >
<method name="doEnterDown">
 Debug.write('Nice day if it do not rain'+userMsg.getText());
           chatMsg.setText(chatMsg.getText()+" \n "+userMsg.getText());
userMsg.setText ("");
           </method>
</edittext>
  </window>

 </canvas>
version 3
   <class name="scrollinputtext" clip="true">
        <attribute name="text" type="html" value=""/>
        <method name="getText">
            return inp.getText();
        </method>
        <method name="setText" args="t">
            inp.setText(t);
        </method>
        <inputtext fontsize="18" name="inp" id="me" height="$
 {parent.height}" width="${parent.width - 20}" multiline="true"
 text="${parent.text }">
            <attribute name="lineheight" value="$
 {this.getTextHeight ()/this.maxscroll}"/>   <!-- fix this -->
            <attribute name="maxheight" value="${ this.height +
 this.lineheight * (this.maxscroll - 1)}"/>
            <attribute name="onpos" value="null"/>
            <attribute name="pos" value="0" setter="setPos(pos);"/>
            <method event="oninit">
                Debug.write('oninit imp', this, this.maxscroll,
 this.scroll);
            </method>
            <method event="onmaxscroll">
                Debug.write('onmaxscroll');
            </method>

            <method name="setPos" args="p">
                if (this.isinited) {
                    this.setScroll(1 - (p / this.lineheight));
                    this.pos = p;
                    if (this.onpos) this.onpos.sendEvent(p);
                }
            </method>
            <method event="onscroll">
                this.setPos(-this.lineheight * (this.scroll - 1),
 true);
            </method>
        </inputtext>
        <scrollbar axis="y" scrollattr="pos"
            stepsize="${ parent.inp.lineheight}" scrollmax="$
 {parent.inp.maxheight}"/>
    </class>




>
> On 3/10/07, Benjamin Shine <ben at laszlosystems.com> wrote:
> >
> >
> > On Mar 10, 2007, at 6:01 AM, gaurav wrote:
> >
> > > it doesnt solve my problem as scroll bar doesn't automatically move
> > > down as more text is added programatically  ....refering to http://
> > > forum.openlaszlo.org/showthread.php?threadid=740 looks like very
> > > old issue ...i hope it will be resolved soon as its basic
> > > issue !!...and it doesn't leave a good impression new converts ->
> > > http://rifers.org/blogs/gbevin/2005/3/8/wasting_time_with_laszo
> >
> > It *is* really hard to get started, especially with a codebase
> > (legals) that hasn't fully passed QA yet. Seriously, you'd be bettter
> > off using a stable 3.4.0 build, making your example work as desired
> > there, then port it to OL4. Or give ito to us as a working standalone
> > 3.4 example and we'll make it work in
> >
> > We do use a scrollable inputtext successfully in laszlomail.com, so
> > it *has* worked between from sometime in 2005 to the 3.4.0 tag, which
> > is a few weeks old. We may have broken it in but we'll surely want to
> > fix that. Can you take a look at the tests in lps/components/
> > incubator and test/text. I'm pretty sure there's a test for exactly
> > what you're trying to do.
> >
> > I'm cc'ing Raju Bitter; he can probably offer you a bit more useful
> > encouragement.
> >
> > PS If you keep reading Geert's blog, he pretty much falls in love
> > with Laszlo. See http://developers.sun.com/champions/bevin.html :)
> >
> > >
> > > On 3/10/07, Benjamin Shine < ben at laszlosystems.com> wrote:
> > >
> > > Open Laszlo 3.4 has the best text handling right now.
> > > Legals text handling might well still have bugs. If the examples in
> > > the legals developer's guide
> > > http://labs.openlaszlo.org/legals-nightly/docs/guide/
> > > text.html#text.multiline
> > > look different from the examples in the 3.4 version of the
> > > developer's guide
> > > http://labs.openlaszlo.org/trunk-nightly/docs/guide/
> > > text.html#text.multiline
> > > then we've probably got some bugs -- please do report them.
> > >
> > > A code sample that works in trunk (3.4) but doesn't work in legals
> > > would be most helpful to identifying and fixing the bugs.
> > >
> > >
> > >
> > >
> > > On Mar 9, 2007, at 4:21 AM, pagux labs wrote:
> > >
> > >> Hi Guys,
> > >> I  have been evaluation openlaszlo(legals) after working on
> > >> another ajax framework called echo2 & GWT .....
> > >>
> > >> I am trying multi line edittext in laszlo  haven't succeed this
> > >> far (in 3rd version i can see scroll bars but after 3 -5 lines but
> > >> srcoll bars doesnt automatically move down when more lines are
> > >> added ) , also unable to find any textarea component
> > >>
> > >>
> > >> Can anyone suggest a solution ?
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> MY Code
> > >>
> > >> version 1
> > >>
> > >> <canvas width="700" debug="true" >
> > >>
> > >>   <window title="Alabot Answers" x="10" y="10"
> > >>           width="220" height="260" >
> > >> <view width="220" height="260" />
> > >>
> > >>
> > >>     <edittext x="10" y="20" width="175" height="140"
> > >> enabled="false" id="chatMsg" >
> > >>  <scrollbar/>
> > >> </edittext>
> > >>     <edittext x="10" y="175" width="175"  doesenter="true"
> > >> id="userMsg"  >
> > >> <method name="doEnterDown">
> > >>  Debug.write('Nice day if it do not rain'+userMsg.getText());
> > >>            chatMsg.setText(chatMsg.getText()+" \n "+userMsg.getText
> > >> ());
> > >> userMsg.setText("");
> > >>            </method>
> > >> </edittext>
> > >>   </window>
> > >>
> > >>  </canvas>
> > >>
> > >>
> > >>
> > >> version 2
> > >>
> > >> <canvas width="700" debug="true" >
> > >>
> > >>   <window title="Alabot Answers" x="10" y="10"
> > >>           width="220" height="260" >
> > >> <view width="220" height="260" />
> > >>
> > >> <view name="main" x="10" y="20" width="175" height="140" clip="true">
> > >>     <view name="contents">
> > >>       <text multiline="true" id="chatMsg">
> > >>
> > >>       </text>
> > >>     </view>
> > >>  <scrollbar/>
> > >>    </view>
> > >>     <edittext x="10" y="175" width="175"  doesenter="true"
> > >> id="userMsg"  >
> > >> <method name="doEnterDown">
> > >>  Debug.write('Nice day if it do not rain'+userMsg.getText());
> > >>            chatMsg.setText(chatMsg.getText ()+" \n "+userMsg.getText
> > >> ());
> > >> userMsg.setText ("");
> > >>            </method>
> > >> </edittext>
> > >>   </window>
> > >>
> > >>  </canvas>
> > >> version 3
> > >>    <class name="scrollinputtext" clip="true">
> > >>         <attribute name="text" type="html" value=""/>
> > >>         <method name="getText">
> > >>             return inp.getText();
> > >>         </method>
> > >>         <method name="setText" args="t">
> > >>             inp.setText(t);
> > >>         </method>
> > >>         <inputtext fontsize="18" name="inp" id="me" height="$
> > >>  {parent.height}" width="${parent.width - 20}" multiline="true"
> > >>  text="${ parent.text }">
> > >>             <attribute name="lineheight" value="$
> > >>  {this.getTextHeight ()/this.maxscroll}"/>   <!-- fix this -->
> > >>             <attribute name="maxheight" value="${ this.height +
> > >>  this.lineheight * (this.maxscroll - 1)}"/>
> > >>             <attribute name="onpos" value="null"/>
> > >>             <attribute name="pos" value="0" setter="setPos(pos);"/>
> > >>             <method event="oninit">
> > >>                 Debug.write('oninit imp', this, this.maxscroll,
> > >>  this.scroll);
> > >>             </method>
> > >>             <method event="onmaxscroll">
> > >>                 Debug.write('onmaxscroll');
> > >>             </method>
> > >>
> > >>             <method name="setPos" args="p">
> > >>                 if ( this.isinited) {
> > >>                     this.setScroll(1 - (p / this.lineheight));
> > >>                     this.pos = p;
> > >>                     if (this.onpos) this.onpos.sendEvent(p);
> > >>                 }
> > >>             </method>
> > >>             <method event="onscroll">
> > >>                 this.setPos(-this.lineheight * (this.scroll - 1),
> > >>  true);
> > >>             </method>
> > >>         </inputtext>
> > >>         <scrollbar axis="y" scrollattr="pos"
> > >>             stepsize="${ parent.inp.lineheight}" scrollmax="$
> > >>  { parent.inp.maxheight}"/>
> > >>     </class>
> > >>
> > >> --
> > >> All I need is a spark....
> > >
> > >
> > >
> > >
> > > --
> > >
> > >                          ''~``
> > >                         ( o o )
> > > +--------------.oooO--(_)--Oooo.------------------+
> > > |                                                           |
> > > |  gp's email  .oooO                                |
> > > |                    (   )   Oooo.                      |
> > > +---------------------\ (----(   )-------------------------+
> > >                        \_)    ) /
> > >                              (_/
> >
> > Benjamin Shine
> > Software Engineer, Open Laszlo / Laszlo Systems
> > ben at laszlosystems.com
> >
> >
> >
> >
>
>
> --
>
>                          ''~``
>                         ( o o )
> +--------------.oooO--(_)--Oooo.------------------+
> |                                                           |
> |  gp's email  .oooO                                |
> |                    (   )   Oooo.                      |
> +---------------------\ (----(   )-------------------------+
>                        \_)    ) /
>                              (_/
>



-- 

                         ''~``
                        ( o o )
+--------------.oooO--(_)--Oooo.------------------+
|                                                           |
|  gp's email  .oooO                                |
|                    (   )   Oooo.                      |
+---------------------\ (----(   )-------------------------+
                       \_)    ) /
                             (_/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20070311/a8699539/attachment-0001.html


More information about the Laszlo-user mailing list