Using text morph to save characters

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

Using text morph to save characters

Michael Rice-3
This may not be an appropriate way to save characters in the order they are generated. This isn't working. Perhaps there's a better way?

Two scripts:
(1) clear1: empties out a TextMorph
(2) addChar: inserts an 'a' or a 'b' at cursor position. Advances cursor position.

Michael



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

textbuffer.png (25K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using text morph to save characters

Bert Freudenberg
On 24.04.2011, at 17:53, michael rice wrote:

> This may not be an appropriate way to save characters in the order they are generated. This isn't working. Perhaps there's a better way?
>
> Two scripts:
> (1) clear1: empties out a TextMorph
> (2) addChar: inserts an 'a' or a 'b' at cursor position. Advances cursor position.
>
> Michael

What exactly is "not working"?

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using text morph to save characters

Michael Rice-3
SorryI wasn't more explicit.

I'm generating a(s) and b(s). If I initially generate two a(s) in a row, and then a b, the b gets put between the two a(s), not at either end of the string. Likewise, if I initially generate two b(s) in a row, and then an a, the a gets inserted between the two b(s), not at either end of the string, as would be expected.

Michael

--- On Tue, 4/26/11, Bert Freudenberg <[hidden email]> wrote:

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Using text morph to save characters
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Tuesday, April 26, 2011, 6:24 AM

On 24.04.2011, at 17:53, michael rice wrote:

> This may not be an appropriate way to save characters in the order they are generated. This isn't working. Perhaps there's a better way?
>
> Two scripts:
> (1) clear1: empties out a TextMorph
> (2) addChar: inserts an 'a' or a 'b' at cursor position. Advances cursor position.
>
> Michael

What exactly is "not working"?

- Bert -


_______________________________________________
Beginners mailing list
Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using text morph to save characters

Bert Freudenberg
The new characters are inserted before the current cursor position. So if the cursor is "1" then the new characters are inserted before the text. Now if the cursor is the same as the count of characters, they are inserted before the last character. You can verify that by "clearing" the Text to e.g. "X".

I'm not really sure what the rationale for this behavior is. I was surprised. Asking on the Squeakland list is a good idea for Etoys issues like this.

- Bert -

On 26.04.2011, at 14:26, michael rice wrote:

SorryI wasn't more explicit.

I'm generating a(s) and b(s). If I initially generate two a(s) in a row, and then a b, the b gets put between the two a(s), not at either end of the string. Likewise, if I initially generate two b(s) in a row, and then an a, the a gets inserted between the two b(s), not at either end of the string, as would be expected.

Michael

--- On Tue, 4/26/11, Bert Freudenberg <[hidden email]> wrote:

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Using text morph to save characters
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Tuesday, April 26, 2011, 6:24 AM

On 24.04.2011, at 17:53, michael rice wrote:

> This may not be an appropriate way to save characters in the order they are generated. This isn't working. Perhaps there's a better way?
>
> Two scripts:
> (1) clear1: empties out a TextMorph
> (2) addChar: inserts an 'a' or a 'b' at cursor position. Advances cursor position.
>
> Michael

What exactly is "not working"?

- Bert -


_______________________________________________
Beginners mailing list
<a ymailto="mailto:Beginners@lists.squeakfoundation.org" href="x-msg://257/mc/compose?to=Beginners@lists.squeakfoundation.org">Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using text morph to save characters

Steve Thomas
Yes we need a way to append in Etoys.

On Tue, Apr 26, 2011 at 8:41 AM, Bert Freudenberg <[hidden email]> wrote:
The new characters are inserted before the current cursor position. So if the cursor is "1" then the new characters are inserted before the text. Now if the cursor is the same as the count of characters, they are inserted before the last character. You can verify that by "clearing" the Text to e.g. "X".

I'm not really sure what the rationale for this behavior is. I was surprised. Asking on the Squeakland list is a good idea for Etoys issues like this.

- Bert -

On 26.04.2011, at 14:26, michael rice wrote:

SorryI wasn't more explicit.

I'm generating a(s) and b(s). If I initially generate two a(s) in a row, and then a b, the b gets put between the two a(s), not at either end of the string. Likewise, if I initially generate two b(s) in a row, and then an a, the a gets inserted between the two b(s), not at either end of the string, as would be expected.

Michael

--- On Tue, 4/26/11, Bert Freudenberg <[hidden email]> wrote:

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Using text morph to save characters
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Tuesday, April 26, 2011, 6:24 AM

On 24.04.2011, at 17:53, michael rice wrote:

> This may not be an appropriate way to save characters in the order they are generated. This isn't working. Perhaps there's a better way?
>
> Two scripts:
> (1) clear1: empties out a TextMorph
> (2) addChar: inserts an 'a' or a 'b' at cursor position. Advances cursor position.
>
> Michael

What exactly is "not working"?

- Bert -


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



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



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