SSブログ

NSTextField [ASOC]

NSTextField class


NSTextFieldImage.png

 

 (2018/6/27更新)

 

(* プロパティの作成 *)

 

property textfield1 : missing value

 

    NSTextViewを操作するために用います。

 

(* テキストの表示 *)

 

textfield1's setTitleWithMnemonic_("文字")            -- |ニーモニックテキスト(テキスト書き出し)| 

textfield1's setStringValue_("文字")                         -- |プレーンテキスト(テキスト書き出し)| 

 

    どちらでもテキスト表示ができる。

 

(* 数値として表示 *)

 

textField1's setIntegerValue_(|整数|)                      -- |数値で書き出し| 

 

    数値(整数)を渡すことができる。実数や4桁以上は表示には注意。

  setIntegerValue_(123456.7)

  --> 123,457 

 

(* テキストの読み出し *)

 

set ans to textField1's stringValue()                 -- |テキストとして読み込み| 

 

    C言語テキストなので、外に出力(display dialog など)する場合は as textでテキスト化が必要

 

(* フィールド内を数値として読み出し *)

 

set ans to textField1's integerValue()                -- |数値として読み込み| 

 

    フィールド内を数値として整数値を取得します。取得できない場合は 0 を返します

 

(* フレーム情報 *)

 

set ans to textfield1's frame()                -- |フレーム情報の取得| 

 

textfield1's setFrameOrigin_({x, y})    -- |貼り付けてあるViewの左下を原点としてフレームの位置指定| 

textfield1's setFrameSize_({w, h})         -- |フレームのサイズ指定| 

 

    貼り付けたビューから見た位置の取得・移動

 

(* フレーム角度 *)

 

textfield1's frameRotation()                  -- |フレームの角度を取得| 

 

    貼り付けたビューから見た角度(貼り付けた元のビューの回転角(角度が0ではない)は考慮しない)

 

(* 文字色の取得 *)

 

textfield1's textColor()                      -- |文字色を取得| 

textfield1's textColor()'s redComponent()     -- |文字の赤色(Red)要素を取得| 

textfield1's textColor()'s greenComponent()   -- |文字の緑色(Green)要素を取得| 

textfield1's textColor()'s blueComponent()    -- |文字の青色(Blue)要素を取得| 

textfield1's textColor()'s alphaComponent()   -- |文字の不透明度(Alpha)要素を取得| 

 

    文字の色の取得します。

後半4行のRGB+Aは、デフォルトのシステムカラーなどのRGB以外では場合はエラーになります。

 

(* 文字色の設定 *)

 

textfield1's setTextColor_(theColor)         -- |文字色を変更| 

 

    文字の色の変更します。theColorの設定は下記で

    --固有色で設定

    set theColor to current application's class "NSColor"'s redColor    --||

    set theColor to current application's class "NSColor"'s greenColor  --||

    set theColor to current application's class "NSColor"'s blueColor   --||

    set theColor to current application's class "NSColor"'s clearColor  --|透明|

     他に、cyanColor,magentaColor,yellowColor,orangeColor,purpleColor,brownColor,

    blackColor,darkGrayColor,grayColor,lightGrayColor,whiteColor など

    --数値で設定(RGB + Alpha値を0.0~1.0で設定)

    set {r,g,b,a} to {0.0, 0.5, 0.2, 1.0}

    set theColor to current application's class "NSColor"'s ¬ 

          colorWithCalibratedRed_green_blue_alpha_(r,g,b,a)

 

 

(* 背景色の設定 *)

 

textfield1's setBackgroundColor_(theColor)          -- |背景色変更(テキストの背景色が邪魔に?)| 

textfield1's setDrawsBackground_(true)                   -- |背景色変更の許可|

 

    背景色は文字に対してとなるので、思ったような変更ができない。

 

(* テキスト選択の許可 *)

 

textfield1's setSelectable_(true)                              -- |フィールド選択の許可|

textfield1's setSelectable_(false)                            -- |フィールド選択の不許可|

 

    フィールドの選択可能かの設定。すでに選択されている場合は、設定が反映されないので注意。

 

(* テキストの編集を許可 *)

 

textfield1's setEditable_(true)                               -- |編集の可能かを許可|

textfield1's setEditable_(false)                             -- |編集の可能かを不許可|

 

    フィールド内のテキストの編集を許可するかの設定。

 

(* フィールド内を選択状態に *)

 

textfield1's selectText_(me)                                    -- |選択状態にする|

 

    フィールド内のテキストを選択状態にします。

 

 

(* フィールドの枠の設定 *)

 

set f to textfield1's isBordered()                         -- |フィールドの枠の有無を確認|

 

textfield1's setBordered_(true)                             -- |フィールドの枠を表示する設定|

 

    枠線の有無確認と設定。

 

(* フィールドのベゼル(立体の枠)の設定 *)

 

set f to textfield1's isBezeled()                          -- |フィールドのベゼルの有無の確認|

 

textfield1's setBezeled_(true)                              -- |フィールドのベゼルを表示する設定|

 

    ベゼル枠の有無確認と設定。

 

 

(* フォントの設定 *)

 

set ans to textfield1's |font|                                         -- |フォント設定の取得|

 

textfield1's setFont_(current application's class "NSFont"'s ¬ 

  systemFontOfSize_(24.0))                                                  -- |フォントサイズの変更(SystemFont)|

 

textfield1's setFont_(current application's class "NSFont"'s ¬ 

  userFontOfSize_(18.0))                                                      -- |フォントサイズの変更(userFont)|

 

textfield1's setFont_(current application's class "NSFont"'s ¬ 

  fontWithName:"Osaka" |size|:24.0)                              -- |フォントの種類とサイズの変更|

 

    フィールド内のテキストのフォントの設定。

 

 

 

調査続行中

 

 

 


コメント(0) 
共通テーマ:パソコン・インターネット

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

※ブログオーナーが承認したコメントのみ表示されます。
NSViewNSButton ブログトップ

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。