how to set the cursor position in TextMorph

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

how to set the cursor position in TextMorph

Celal Ziftci
Hi,
I am having problem in setting the cursor to a certain position in
TextMorph. I am trying the cursorWrapped: message, but it seems to be
not working (or I am misunderstanding its meaning). Any help or pointers
would be appreciated.
Thanks,

- Celal Ziftci

Reply | Threaded
Open this post in threaded view
|

Re: how to set the cursor position in TextMorph

Frank Urbach
Hi Celal,

Better to know is what do you want to do. The accessor cursorWrapped: work very well and brings the curosor
of the TextMorph to the right position. The little example below is how I try to get the answer on your question.

"initialize the TextMorph"
karl := TextMorph new openInWorld.
karl contents: 'here comes the mouse'.

"Show where the cursor is"
Transcript show: karl cursor;cr.
"result ==1"

"change the position of the cursor"
karl cursorWrapped: 6.

"Show where the cursor is"
Transcript show: karl cursor.
"result == 6"

Cheers,
  Frank

-------- Original Message --------
Subject: how to set the cursor position in TextMorph (09-Mai-2006 19:47)
From:    Celal Ziftci <[hidden email]>
To:      [hidden email]

> Hi,
> I am having problem in setting the cursor to a certain position in
> TextMorph. I am trying the cursorWrapped: message, but it seems to be
> not working (or I am misunderstanding its meaning). Any help or pointers
> would be appreciated.
> Thanks,
>
> - Celal Ziftci
>



Reply | Threaded
Open this post in threaded view
|

Re: how to set the cursor position in TextMorph

Celal Ziftci-2
In reply to this post by Celal Ziftci
Hi Frank,
I think I'm getting the meaning of cursor wrong.
So basicly what I want to do is the following. I want to set the caret position in the textmorph using some smalltalk code instead of using the mouse.
As an example, assume I have the following text in a textmorph and | is the place my caret is currently at:

smallt|alk

Now I want to move the caret to another place like:

sm|alltalk

but not by clicking there, using some code instead.
Is this possible at all? Do I need to imitate firing an event (something like mouse down event)?
Thanks for any help.

- Celal Ziftci


-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------


> Hi Celal,

> Better to know is what do you want to do. The accessor cursorWrapped: work very well and brings the curosor
> of the TextMorph to the right position. The little example below is how I try to get the answer on your question.

> "initialize the TextMorph"
> karl := TextMorph new openInWorld.
> karl contents: 'here comes the mouse'.

> "Show where the cursor is"
> Transcript show: karl cursor;cr.
> "result ==1"

> "change the position of the cursor"
> karl cursorWrapped: 6.

> "Show where the cursor is"
> Transcript show: karl cursor.
> "result == 6"

> Cheers,
>   Frank

-------- Original Message --------
Subject: how to set the cursor position in TextMorph (09-Mai-2006 19:47)
From:    Celal Ziftci <[hidden email]>
To:      [hidden email]

>> Hi,
>> I am having problem in setting the cursor to a certain position in
>> TextMorph. I am trying the cursorWrapped: message, but it seems to be
>> not working (or I am misunderstanding its meaning). Any help or pointers
>> would be appreciated.
>> Thanks,
>>
>> - Celal Ziftci
>

Reply | Threaded
Open this post in threaded view
|

Re: how to set the cursor position in TextMorph

Celal Ziftci
In reply to this post by Celal Ziftci

Hi Frank,
I think I'm getting the meaning of cursor wrong.
So basicly what I want to do is the following. I want to set the caret
position in the textmorph using some smalltalk code instead of using the
mouse.
As an example, assume I have the following text in a textmorph and | is
the place my caret is currently at:

smallt|alk

Now I want to move the caret to another place like:
sm|alltalk

but not by clicking there, using some code instead.
Is this possible at all? Do I need to imitate firing an event (something
like mouse down event)?
Thanks for any help.

- Celal Ziftci


-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------



> Hi Celal,


> Better to know is what do you want to do. The accessor cursorWrapped:
> work very well and brings the curosor of the TextMorph to the right
> position. The little example below is how I try to get the answer on
> your question.


> "initialize the TextMorph"
> karl := TextMorph new openInWorld. karl contents: 'here comes the mouse'.


> "Show where the cursor is"
> Transcript show: karl cursor;cr.
> "result ==1"


> "change the position of the cursor"
> karl cursorWrapped: 6.


> "Show where the cursor is"
> Transcript show: karl cursor.
> "result == 6"


> Cheers,
>   Frank


-------- Original Message --------
Subject: how to set the cursor position in TextMorph (09-Mai-2006 19:47)
From:    Celal Ziftci <[hidden email]>
To:      [hidden email]

>> Hi,
>> I am having problem in setting the cursor to a certain position in
>> TextMorph. I am trying the cursorWrapped: message, but it seems to be
>> not working (or I am misunderstanding its meaning). Any help or
>> pointers would be appreciated.
>> Thanks,
>>
>> - Celal Ziftci
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how to set the cursor position in TextMorph

Hernan Tylim-2
Hi Celal, I don´t have a squeak image at hand so I can't give you exact names or working code, but what you need need to do is to check the class ParagraphEditor (or something like that).

The text cursor (the caret) in Squeak is what in the text input classes is called an editor. The caret, is not really a cursor but a visual representation of the selection, which when has a size 0 looks like a normal cursor.

Look at the ParagraphEditor and look at the method categories, and you will surely find methods that deals with cursor movement. Actually, somewhere in there you will find the exact code that is executed each time an arrow key is pressed.

Regards,
Hernán

On 5/10/06, Celal Ziftci <[hidden email]> wrote:

Hi Frank,
I think I'm getting the meaning of cursor wrong.
So basicly what I want to do is the following. I want to set the caret
position in the textmorph using some smalltalk code instead of using the
mouse.
As an example, assume I have the following text in a textmorph and | is
the place my caret is currently at:

smallt|alk

Now I want to move the caret to another place like:
sm|alltalk

but not by clicking there, using some code instead.
Is this possible at all? Do I need to imitate firing an event (something
like mouse down event)?
Thanks for any help.

- Celal Ziftci


-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------



> Hi Celal,


> Better to know is what do you want to do. The accessor cursorWrapped:
> work very well and brings the curosor of the TextMorph to the right
> position. The little example below is how I try to get the answer on
> your question.


> "initialize the TextMorph"
> karl := TextMorph new openInWorld. karl contents: 'here comes the mouse'.


> "Show where the cursor is"
> Transcript show: karl cursor;cr.
> "result ==1"


> "change the position of the cursor"
> karl cursorWrapped: 6.


> "Show where the cursor is"
> Transcript show: karl cursor.
> "result == 6"


> Cheers,
>   Frank


-------- Original Message --------
Subject: how to set the cursor position in TextMorph (09-Mai-2006 19:47)
From:    Celal Ziftci <[hidden email]>
To:      [hidden email]

>> Hi,
>> I am having problem in setting the cursor to a certain position in
>> TextMorph. I am trying the cursorWrapped: message, but it seems to be
>> not working (or I am misunderstanding its meaning). Any help or
>> pointers would be appreciated.
>> Thanks,
>>
>> - Celal Ziftci
>
>





--
Saludos,
Hernán


Reply | Threaded
Open this post in threaded view
|

RE: how to set the cursor position in TextMorph

Gary Chambers
In reply to this post by Celal Ziftci
How about

        myTextMorph setSelection: (7 to: 6)

Or change the range to have a selection instead of a caret.


> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Celal
> Ziftci
> Sent: 10 May 2006 3:50 PM
> To: [hidden email]
> Subject: Re: how to set the cursor position in TextMorph
>
>
>
> Hi Frank,
> I think I'm getting the meaning of cursor wrong.
> So basicly what I want to do is the following. I want to set the caret
> position in the textmorph using some smalltalk code instead of using the
> mouse.
> As an example, assume I have the following text in a textmorph and | is
> the place my caret is currently at:
>
> smallt|alk
>
> Now I want to move the caret to another place like:
> sm|alltalk
>
> but not by clicking there, using some code instead.
> Is this possible at all? Do I need to imitate firing an event (something
> like mouse down event)?
> Thanks for any help.
>
> - Celal Ziftci
>
>
> ------------------------------------------------------------------
> -------------------------------------------
>
> ------------------------------------------------------------------
> -------------------------------------------
>
> ------------------------------------------------------------------
> -------------------------------------------
>
>
>
> > Hi Celal,
>
>
> > Better to know is what do you want to do. The accessor cursorWrapped:
> > work very well and brings the curosor of the TextMorph to the right
> > position. The little example below is how I try to get the answer on
> > your question.
>
>
> > "initialize the TextMorph"
> > karl := TextMorph new openInWorld. karl contents: 'here comes
> the mouse'.
>
>
> > "Show where the cursor is"
> > Transcript show: karl cursor;cr.
> > "result ==1"
>
>
> > "change the position of the cursor"
> > karl cursorWrapped: 6.
>
>
> > "Show where the cursor is"
> > Transcript show: karl cursor.
> > "result == 6"
>
>
> > Cheers,
> >   Frank
>
>
> -------- Original Message --------
> Subject: how to set the cursor position in TextMorph (09-Mai-2006 19:47)
> From:    Celal Ziftci <[hidden email]>
> To:      [hidden email]
>
> >> Hi,
> >> I am having problem in setting the cursor to a certain position in
> >> TextMorph. I am trying the cursorWrapped: message, but it seems to be
> >> not working (or I am misunderstanding its meaning). Any help or
> >> pointers would be appreciated.
> >> Thanks,
> >>
> >> - Celal Ziftci
> >
> >
>
>

Reply | Threaded
Open this post in threaded view
|

Re: how to set the cursor position in TextMorph

Celal Ziftci
In reply to this post by Celal Ziftci
I think a TextMorph doesnt have such a method called 'setSelection'.
I tried running it but it doesn't understand the message.
Thanks for the response though.

- Celal


------------------------------------------------------------------------------------

How about

        myTextMorph setSelection: (7 to: 6)

Or change the range to have a selection instead of a caret.


Reply | Threaded
Open this post in threaded view
|

RE: how to set the cursor position in TextMorph

Gary Chambers
Sorry, that was for PluggableTextMorph. Better to use the pluggable version
IMO.

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Celal
> Ziftci
> Sent: 11 May 2006 3:34 AM
> To: [hidden email]
> Subject: Re: how to set the cursor position in TextMorph
>
>
> I think a TextMorph doesnt have such a method called 'setSelection'.
> I tried running it but it doesn't understand the message.
> Thanks for the response though.
>
> - Celal
>
>
> ------------------------------------------------------------------
> ------------------
>
> How about
>
> myTextMorph setSelection: (7 to: 6)
>
> Or change the range to have a selection instead of a caret.
>
>


Reply | Threaded
Open this post in threaded view
|

RE: how to set the cursor position in TextMorph

Gary Chambers
If you want to use a TextMorph try the following:


myTextMorph editor selectFrom: 2 to: 1.
ActiveHand newKeyboardFocus: myTextMorph.
myTextMorph changed

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Gary
> Chambers
> Sent: 11 May 2006 7:11 PM
> To: The general-purpose Squeak developers list
> Subject: RE: how to set the cursor position in TextMorph
>
>
> Sorry, that was for PluggableTextMorph. Better to use the
> pluggable version
> IMO.
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]]On Behalf Of Celal
> > Ziftci
> > Sent: 11 May 2006 3:34 AM
> > To: [hidden email]
> > Subject: Re: how to set the cursor position in TextMorph
> >
> >
> > I think a TextMorph doesnt have such a method called 'setSelection'.
> > I tried running it but it doesn't understand the message.
> > Thanks for the response though.
> >
> > - Celal
> >
> >
> > ------------------------------------------------------------------
> > ------------------
> >
> > How about
> >
> > myTextMorph setSelection: (7 to: 6)
> >
> > Or change the range to have a selection instead of a caret.
> >
> >
>
>