Curl Global Community

Full Version: RichTextAreaについて
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
こんにちは。

RichTextAreaについて質問があります。

RichTextArea内のフォントファミリードロップダウンやフォントサイズドロップダウンの内容を
変える方法を教えて頂きたいです。

もう1点、
初期値としてメイリオの22ptと設定する方法はあるのでしょうか?

ご教授よろしくお願いいたします。
上記いずれも、RichTextArea.data-model (RichTextStringDataModel)の属性変更で実現可能と思います。
例:

Code:
{let rta:RichTextArea =
  {RichTextArea value={RichTextString.from-string "Tメイリョウ日本語22ptest"},
    {on AttachEvent do
      {(rta.data-model asa RichTextStringDataModel).set-attribute "font-family", "メイリオ"}
      {(rta.data-model asa RichTextStringDataModel).set-attribute "font-size", 22pt}

    }
  }
}

{value rta}
>heavybugtrackerさん

回答ありがとうございます!

例にあるサンプルコードを実行したところフォントやサイズが変更されました。
しかし、valueで設定している値を全て削除すると自動的にフォントとサイズが「sans-serif 10pt」になってしまいました。
※Value値が空だと自動的にフォントやサイズが変わるようです...
今回やりたいことはRichTextAreaを画面に表示しますが、フォントとサイズをプログラム内で指定し
ユーザーが入力するとき(空白状態から)はメイリオの22ptといった条件で入力することです。

追加質問があるのですが、
フォントとサイズのリスト内はどうやって編集すればよいでしょうか。
使わないフォントが沢山ありますのである程度数を絞って表示したり、
サイズも同様に使うものを絞りたいです。

以上、よろしくおねがいします!

長い間見れてなく、ご回答が遅くなって失礼しました。

romさんのやりたいことはRichTextAreaのソースコードをCurlの開発環境の
インストールフォルダにあるOPEN-CONTROLSから取得し、改造する方が無難です。
(OPEN-CONTROLSのソースコードは通常次の場所にあります:
C:\Program Files (x86)\Curl Corporation\Surge\9\ide\gui\controls)


それが嫌でしたら、ハック的なやり方もあります。
Curlのグラフィック階層の考え方を利用して、対象のグラフィックを探すことです。

次のコードをご参考になれれば幸いです。
PHP Code:
{curl 8.0 applet}
{
define-proc public {find-target-in
                        g
:Box,
                        
t:Type,
                        
layer:int 5,
                        
sclass:String "rta-font-family-control",
                        
processed-layer:int}:#Box
    
    
set processed-layer processed-layer 1
    
{if processed-layer layer then
        
{return null}
    }

    {if-
non-null gc g.graphical-children then
        
{while true do
            {
def (child:anyeof?:bool) = {gc.read-one}}
            {
output "Child TYPE:" & {type-of child}}
            {
output "child style-class:" child.style-class}
            {
output "sclass:" sclass}
            
            {if {
type-of child} == and child.style-class == sclass then
                
{return child asa Box}
            }
            {if 
not (child isa Boxthen {continue}}
            {return
                {
find-target-in
                    child asa Box
,
                    
t,
                    
layer layer,
                    
sclass sclass,
                    
processed-layer
                
}
            }
        }
     else
        {return 
null}
    }
}

{
let rta:RichTextArea = {RichTextArea}}

{
spaced-vbox
    rta
,
    {
CommandButton
        
{on Action do
            || 
Get font-size dropdownlist
            
{def font-family-ddl =
                {
find-target-in rtaDropdownListlayer=6sclass="rta-font-family-control"0}
            }
            {
def font-size-ddl =
                {
find-target-in rtaDropdownListlayer=6sclass="rta-font-size-control"0}
            }
            {
output font-family-ddl}
            {
output font-size-ddl}
        }
    }


上記Font-familyおよびFont-sizeのドロップダウンリストのインスタンスを取得出来たら、中の値(リスト)が変更可能になりますので、ご期待の動きにはできるかと思います。