


 
 
 
 
 
 
 |
DelphiXE4 [FMX]チェックボックス(CheckBox) 2015/04/02 |
前回は[Standard]内の「ボタン(Button)」について記述しましたので、今回は、同じく[Standard]内の「チェックボックス(CheckBox)」について記述します。
【Delphi2010の記事はこちら】
【DelphiXE3[VCLアプリケーション]の記事はこちら】
【DelphiXE3[FMXアプリケーション]の記事はこちら】
XE4(FMX)
FMX.StdCtrls.TCheckBox |
XE3(FMX)
FMX.Controls.TCheckBox |
 |  |
 |  |
(ヘルプより)
DisableFocusEffect
コントロールのフォーカス効果を無効にするかどうかを示します。
DisableFocusEffectをTrueに設定すると、コントロールはフォーカスされた際に適用される効果を無効にします。通常、FireMonkeyコントロールに対するDisableFocusEffectはFalseです。 |
EnableDragHighlight
コントロール上にオブジェクトがドラッグされた際に、コントロールを強調表示するかどうかを示します。 |
IsChecked
チェックボックスのデフォルトの状態が、オンがオフかを示します。
このチェックボックスがデフォルトの状態で選択されているようにするには、IsCheckedプロパティをTrueに設定します。チェックボックスが再びクリックされると、その選択はクリアされます。 |
IsPressed
チェックボックスのチェックの状態を読み取ります。
チェックボックスがオンの場合にはIsPressed読み取り専用がプロパティはTrueに、そうでなければFalseとなります。 |
|
ユニットが変わってますが、プロパティ・イベントは同じな様子です。
試しに
procedure TForm1.CheckBox1Change(Sender: TObject);
var
s : string ;
begin
s := 'IsChecked:';
if (CheckBox1.IsChecked) then
s := s + 'True'
else
s := s + 'False';
s := s + ' IsPressed:';
if (CheckBox1.IsPressed) then
s := s + 'True'
else
s := s + 'False';
showMessage(s);
end; |
のようにOnChangeイベントで行った場合、
チェックボックスをチェックオン
チェックボックスのチェックが入った後にイベント発生
→ 「IsChecked:True IsPressed:False」表示
チェックボックスをチェックオフ
チェックボックスのチェックが外れた後にイベント発生
→ 「IsChecked:False IsPressed:False」表示
・・・
となります。
procedure TForm1.CheckBox2Click(Sender: TObject);
var
s : string ;
begin
s := 'IsChecked:';
if (CheckBox2.IsChecked) then
s := s + 'True'
else
s := s + 'False';
s := s + ' IsPressed:';
if (CheckBox2.IsPressed) then
s := s + 'True'
else
s := s + 'False';
showMessage(s);
end; |
のようにOnClickイベントで行った場合、
チェックボックスをチェックオン
チェックボックスのチェックが入る前にイベント発生
→ 「IsChecked:False IsPressed:True」表示
チェックボックスをチェックオフ
チェックボックスのチェックが外れる前にイベント発生
→ 「IsChecked:True IsPressed:True」表示
・・・
となります。
ですので OnChange と OnClick とでは動作の挙動が異なりますので、これを意識してプログラミングする必要があります。
チェックボックスを4つ配置してみました。
CheckBox1・2のフォントはデフォルトの「Segoe UI」ですが
CheckBox3のフォントは「Segoe Print」
CheckBox4のフォントは「Segoe Script」にしています。
以下、
CheckBox1 はチェックなし
CheckBox2 はチェックあり
CheckBox3 にフォーカスがある状態で
CheckBox4 の上にマウスを移動している状態、です。
指定無し |
Air.Style |

Amakrits.Style |

AquaGraphite.style |

Blend.Style |

Dark.style |

GoldenGraphite.Style |

Light.Style |

RubyGraphite.style |

Transparent.Style |
既に記述した通り、MacOSX アプリケーションでも動作OKです。
但し、
・上図のように、フォントは同じになりません。
・空白キー(スペースキー)だけを押す事では、オン・オフできません。
shiftキー+空白キーを押す事で、オン・オフできるようです。
という差異はあります。
|
|
バッチファイル
BASIC
C言語のお勉強
拡張子な話
DOSプログラム
Delphi
>Delphi入門編
>Delphi2010
>DelphiXE3
>DelphiXE4
△TOP
▲2015/04/01
2015/04/02
▼2015/04/03
シェアウェア
Script!World
データベース
|