How to find the cursor position relative to its text for TextMorph or RubTextFieldArea

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

How to find the cursor position relative to its text for TextMorph or RubTextFieldArea

kilon.alios
At first I thought that TextMorph>>cursor would return me the position of the cursor relative to its text so if I have a text like "hello" and cursor (that blinking thing) was at "o" it would return 6 but no, whatever position I try it returns always 1 . With rubric I found no way to do this either.

Anyone has a clue, or to I need some kind of pharo dark magic ? Is this a bug , a feature or something in between ?
Reply | Threaded
Open this post in threaded view
|

Re: How to find the cursor position relative to its text for TextMorph or RubTextFieldArea

kilon.alios
and to answer my own question the answer is

TextMorph editor pointIndex.

And now I can create a specialized input field only for time  that automatically formats to HH:MM:SS

On Wed, Nov 11, 2015 at 3:21 PM Dimitris Chloupis <[hidden email]> wrote:
At first I thought that TextMorph>>cursor would return me the position of the cursor relative to its text so if I have a text like "hello" and cursor (that blinking thing) was at "o" it would return 6 but no, whatever position I try it returns always 1 . With rubric I found no way to do this either.

Anyone has a clue, or to I need some kind of pharo dark magic ? Is this a bug , a feature or something in between ?
Reply | Threaded
Open this post in threaded view
|

Re: How to find the cursor position relative to its text for TextMorph or RubTextFieldArea

Pharo Smalltalk Users mailing list
Hello Dimitris,
Why do you use TextMorph and not RubScrolledTextModel or RubTextFieldMorph ?
Cheers
Alain
On 11 Nov 2015, at 16:28, Dimitris Chloupis <[hidden email]> wrote:

and to answer my own question the answer is

TextMorph editor pointIndex.

And now I can create a specialized input field only for time  that automatically formats to HH:MM:SS

On Wed, Nov 11, 2015 at 3:21 PM Dimitris Chloupis <[hidden email]> wrote:
At first I thought that TextMorph>>cursor would return me the position of the cursor relative to its text so if I have a text like "hello" and cursor (that blinking thing) was at "o" it would return 6 but no, whatever position I try it returns always 1 . With rubric I found no way to do this either.

Anyone has a clue, or to I need some kind of pharo dark magic ? Is this a bug , a feature or something in between ?

Reply | Threaded
Open this post in threaded view
|

Re: How to find the cursor position relative to its text for TextMorph or RubTextFieldArea

kilon.alios
because its simpler to understand and because I made it work the way I wanted faster than the Rubric alternatives.

For example finding the cursor position for a RubScrolledTextMorph is even worse and is located at textArea selectionInterval which I did not even find by myself because the name would never have me guessed that selection had anything to do with cursor position. But I was told so by another smalltalker at slack chat.

And even though my code formating worked great with TextMorph via keyStroke message when I tried to port my code to the Rubric keyStroke alternative it stopped working and I did not manage to find out why before I finally managed to find how to get the cursor position from a TextMorph. 

Generally speaking Morphic is my first choice for the simple fact that when it comes to Rubric, Glamour, Spec or whatever else Morphic still remains the basis. So if I am going to learn Morphic anyway then I might as well make it my first choice and when it cant do what I want the easy way then I will look into the alternatives.

Frankly I really like Morphic. Still new to it, but its generally design makes more sense to me than other pharo GUI APIs. 

On Wed, Nov 11, 2015 at 7:30 PM Alain Plantec via Pharo-users <[hidden email]> wrote:
Hello Dimitris,
Why do you use TextMorph and not RubScrolledTextModel or RubTextFieldMorph ?
Cheers
Alain

On 11 Nov 2015, at 16:28, Dimitris Chloupis <[hidden email]> wrote:

and to answer my own question the answer is

TextMorph editor pointIndex.

And now I can create a specialized input field only for time  that automatically formats to HH:MM:SS

On Wed, Nov 11, 2015 at 3:21 PM Dimitris Chloupis <[hidden email]> wrote:
At first I thought that TextMorph>>cursor would return me the position of the cursor relative to its text so if I have a text like "hello" and cursor (that blinking thing) was at "o" it would return 6 but no, whatever position I try it returns always 1 . With rubric I found no way to do this either.

Anyone has a clue, or to I need some kind of pharo dark magic ? Is this a bug , a feature or something in between ?