finding where the cursor is.

Ralph Boland rboland at porchlight.ca
Wed Dec 3 02:33:23 UTC 2003


As part of a gui I have a PluggableTextMorph
that I allow the user to do standard editing
functions. (insert/delete text move cursor
by arrows or mouse).  After each user operation
I need to find out where the mouse cursor is at.
(I need to collect all the text in the morph up to
the point where the mouse is but not beyond.

Is there an easy or generally viewed as correct way to do this?

Any help much appreciated.


Note that I have already implemented a similar feature
in a very complex way.
I have a gui (for a different purpose) where the user cannot change
the text in a PluggableTextMorph but can move
the cursor around.  (The attributes of various text
characters change depending upon where the cursor is)
To implement this I catch things like
cursorUp and cursorLeft to find out where the cursor
is.  This was a lot of work to figure out and implement
and its somewhat buggy.  For example I wanted to highlight
the character where the cursor is to make it more visible
but to implement this I had to change the text a paragraph
contained and in doing so the selected area I marked would
be discarded.  To fix this I seem to need to change base classes which
I didn't want to do so I lived with underlining the character at the
cursor position instead.

One final note for those still with me.
I will be creating a lot of guis (is guis a word?) where the user
will be able to move about a text based object (and in certain 
circumstances actually make changes) and as a result of these
movements things change immediately in other gui objects (or sometimes
the same one)
Thus I would like to implement this kind of feature in as clean and 
portable way as possible (by portable I mean making as few changes as
possible to base classes.
I realize that this is a broad question so answers will likely be 
similarly broad but the more help and more specific the help the
better.  Keep in mind that I know virtually nothing about guis.
I design algorithms. I rarely implement them and and not happy about
implementing guis but I have no choice since I am the only one here
who knows (some) smalltalk.  Actually, so far, I am the only one here.

For those still with me and those not.

Thanks for your patience and hopefully help.



Ralph Boland

By the way all this stuff is for a parser generator tool I am developing
and that I will eventually release into the public domain.
Anyone who likes building guis and wants to jump on board is welcome.

Ralph Boland




More information about the Squeak-dev mailing list