Force keyboard focus and font scaling algorithm
Andreas.Raab at gmx.de
Sun Aug 18 01:07:23 UTC 2002
> 1) Is there some way to force the morph to gain keyboard
> focus when it receives #openInWorld?
Yes. Implement the following method:
"We're entering aWorld"
aWorld ifNil:[^self]. "needs to test for nil"
super intoWorld: aWorld.
aWorld primaryHand keyboardFocus: self.
> 2) I'm having trouble with font sizing (as is probably obvious). I
> currently set each item to a constant height and then set the width
> proportionally. My problem is that I end up with different
> "font sizes" given that some strings have letters with ascenders,
> descenders, etc Is there some algorthm I can use to cause each list
> item to have the same "font size" (and to space the morphs evenly)?
Yes. You need to look at the font metrics to find out the right scaling
factor which is encoded as "units per em square". Have a look at
TTFontReader class>>installTTF: which uses the units per em square to
compute the right scaling factors for a font.
> 3) At some point I hope to implement "smooth scrolling."
> Currently, I delete all submorphs and rebuild them to scroll
> the items.
What a waste of cycles ;-) Try something like:
submorphs do:[:each| each position: position + delta].
and turn on clipping, e.g., "myList clipSubmorphs: true".
More information about the Squeak-dev