I'm working on a modification to my app's usage of MLTE to allow it
(that is, a TXNObject) to resize on the fly whilst the user types
into it (also when other things happen that would change the metrics
of the text, but that's another story and generally more easily
handled ).
I've read thru the posts here about the nuances of view and
destination rectangles, but I'm still having trouble grasping what is
supposed to happen as well as what actually happens.
I start the object at an arbitrary location (actually determined by
our cross platform code) in a window at about the size of one
character at the default font size, and set kTXNNoAutoWrap.
When the user types, I intercept the
kEventTextInputUnicodeForKeyEvent, let MLTE handle the key by calling
CallNextEventHandler ,then check the required text rectangle of the
TXNObject , and set the frame to the width of the required text
rectangle plus a little buffer for the caret (using TXNResizeFrame)
The problem is that when the text input is handled by MLTE, the text
scrolls out of view to the left. I've checked to see if the
destination rect has changed, but it still has the same left bounds
as the view rect.
I've sorta worked around this by resizing the frame an arbitrary
amount before CallNextEventHandler, then 'correcting' it after, but
that doesn't work at all when the alignment is set to centred or
right aligned.
What I'm confused about is how the required rect for text can fall
outside of the destination rect. From my understanding of the
destination rect, it's supposed to be the actual canvas for the text,
and the view is a 'window' onto that, a la scroll views; so how can
the text actually fall outside of the dest rect?
(Also, calling TXNRecalcTextLayout doesn't do anything to readjust
the text to be in the dest rect.)
So,
Is there any way to keep the text from shifting when typing? The
destination rect when I start out is the same left and top as the
view rect, extending out to QD limits to the right and down. after I
type and the required rect shifts to the left, the dest rect is still
the same. I assume mlte is just trying to make sure to show the
cursor, but I want to be able to let it scroll "out of view" and then
resize the view rect so it will show all of the new text as well as
the text cursor
thanks v. much for any assistance, and sorry if I've missed something
obvious.
robb olsen-albright
vernier software & technology
portland, or
p.s. As a bit of background, the mlte is being used as the
implementation of a sort of "sticky note" in an educational app that
combines data aquisition and page layout. It works kinda ok (after I
work around PowerPlant issues and mlte drawing out of turn, etc )
when it is set to a specific size and the scrolling is done within
that size but now we have a feature requirement for next version for
the text annotations to resize to just fit the typed in text, and I'm
looking for any suggestions from anyone who's done anything like this.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden