[plt-scheme] Text field font troubles

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sun Aug 10 01:22:51 EDT 2008

The right way to set a style on a snip is probably to insert it and
then call change-style, rather than trying to use set-style. Styles on
snips are more useful when you write your own snip% class and then
have it draw differently by inspecting get-style.

Robby

On Sat, Aug 9, 2008 at 10:19 PM, Sky O'Mara <skyo at ccs.neu.edu> wrote:
> You're right, thanks for that tip!
>
> I agree that snips are pretty confusing. It would be nice to see some
> examples of how to use them properly.
>
> - Sky O.
>
> On Aug 9, 2008, at 9:37 PM, praimon wrote:
>
>> Thanks,
>> It was helpful to see positions used here.
>> (btw, I think your final (send ed last-position) can be replaced with
>> 'end).
>> But...you too abandoned snips! I wonder what a snip-based version
>> would look like.
>> regards,
>> praimon
>>
>> On Sat, Aug 9, 2008 at 3:07 PM, Sky O'Mara <skyo at ccs.neu.edu> wrote:
>>>
>>> This is what I came up with to make use of change-style:
>>>
>>> (define (insert-red-text str ed)
>>> (let ([red-delta (send (make-object style-delta%) set-delta-foreground
>>> "Red")]
>>>      [end-before (send ed last-position)]) ;; the end of the text before
>>> inserting str
>>>  (send ed insert str end-before)
>>>  (send ed change-style red-delta end-before (send ed last-position))))
>>>
>>> I hope this is a useful example. I agree that the documentation for the
>>> gui
>>> leaves much to be desired.
>>>
>>> - Sky O.
>>>
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.