This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: An unanticipated use for ExtraEmphases
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
I was sitting here modding a tool I use now and then again. I found that I needed to prompt the user to select an object from a list of objects. No problem. Use Dialog>>choose:fromList:values:lines:cancel:.
My problem is that I want to put a cute little icon at the front of each one. Whatever you pass as the fromList: argument though, will be turned into Text objects. Nominally, this usually means the displayString of an object, but you can pass a Text too, and it's happy to use that. That's handy in this case, because ExtraEmphases has the ability to add arbitrary glyphs into a character stream, either before, after, or in lieu of emphasized characters. So it's just a matter of doing something like:
theText emphasizeFrom: 1 to: 1 with: theIcon
This is admittedly a hack. I'm betting Pollock will make things like this easier/more straightforward. But for now, it was kinda nice. BTW, ExtraEmphases by default uses this technique to place a little red stop sign in your code wherever you have a breakpoint inserted.