2016-08-07 8 views
1

特定のフォントでテキストフィールド派生クラスを作成しようとしています。フィールドは正しく作成されますが、フォントは機能しません。テキストフィールドの派生クラスフォントがラケットで機能しない

#lang racket/gui 

; my particular font: 
(define (myfont size) (make-object font% size 'modern 'normal 'bold)) 

(define myframe (new frame% [width 600] [label "MyFrame"])) 

(new text-field% [parent myframe] [label "Usual text-field; font works here:"] [font (myfont 14)]) 

; Following is my text-field derived class with a particular font: 
(define mytf% (class text-field% (field (font (myfont 14))) (super-new))) 
(new mytf% [parent myframe] [label "My text-field derived class; font does not work here:"]) 

(send myframe show #t) 

問題はどこで解決できますか?あなたのコメント/回答ありがとう。

答えて

1

fonttext-field%のパブリックフィールドではありません。 したがって(field (font (myfont 14)))mytf%に新しいフィールドを表示させますが、text-field%では使用しません。

ソリューションは、テキストフィールドのインスタンス化時にフォント情報を渡すことです:

(define mytf% 
    (class text-field% 
    (super-new [font (myfont 14)]))) 
+0

はい、それは動作します。ありがとう。 – rnso

関連する問題