TextMorph

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TextMorph

pascal.vollmer
Hello,

I write a times table application for children: a question, an equals sign, an answer. For the answer field I would like to see a TextMorph. It should be empty, prepared for big size figures and with a big size cursor waiting for input.

I tested TextMorph>>borderedPrototype the contents of which is initialized to 'abc'. Now, when I change 'abc' to an empty string... cursor size is reduced and the first figure that is typed by the user will be small size.

Why this different behavior?

Kind regards
Pascal

Pascal Vollmer
Email: [hidden email]

Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und optional 60 Pay TV Sender, einen elektronischen Programmführer mit Movie Star Bewertungen von TV Movie. Außerdem, aktuelle Filmhits und spannende Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: TextMorph

Mark Volkmann
On Nov 3, 2008, at 4:51 PM, [hidden email] wrote:

> Hello,
>
> I write a times table application for children: a question, an  
> equals sign, an answer. For the answer field I would like to see a  
> TextMorph. It should be empty, prepared for big size figures and  
> with a big size cursor waiting for input.
>
> I tested TextMorph>>borderedPrototype the contents of which is  
> initialized to 'abc'. Now, when I change 'abc' to an empty string...  
> cursor size is reduced and the first figure that is typed by the  
> user will be small size.
>
> Why this different behavior?


I think the issue is that if you want the TextMorph to be larger than  
the text inside it (in your case none), you have to set its extent.  
Here's some code that works for me. Note how I set the extent height  
of "textField" based on the font size of the StringMorph. I set the  
extent width to a fixed value of 100 pixels.

        spaceBetweenMorphs := 10.
        spaceInsideContainer := 10.
       
        container := Morph new.
        container
                layoutPolicy: TableLayout new;
                listDirection: #leftToRight;
                hResizing: #shrinkWrap;
                vResizing: #shrinkWrap;
                layoutInset: spaceInsideContainer;
                cellInset: spaceBetweenMorphs;
                width: 200.

        label := StringMorph contents: 'I''m a label.'.
        font := label font.
        margin := 4.
        height := font lineGrid + (margin * 2).
        container addMorphBack: label.
       
        textField := TextFieldMorph new.
        textField extent: 100@height. "text doesn't display if insufficient  
height"
        container addMorphBack: textField.

---
Mark Volkmann




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners