メインコンテンツまでスキップ
バージョン: 21 R4 BETA

フォームオブジェクト

フォーム上のオブジェクトを編集することで、アプリケーションのフォームを構築しカスタマイズします。 オブジェクトの追加・配置、オブジェクトプロパティの設定、入力規制の追加によるビジネスルールの強化、操作に対して自動実行されるオブジェクトメソッドの追加などをおこなうことができます。

アクティブオブジェクトとスタティックオブジェクト

4D フォームでは多くのビルトイン アクティブ オブジェクトおよび スタティック オブジェクトが提供されています:

  • アクティブオブジェクト はインターフェース機能やデータベースタスクを実行します。 アクティブオブジェクトの種類は、 入力フィールド、コンボボックス、ドロップダウンリスト、ピクチャーボタンなど様々ですが、いずれもデータを表示したり、メモリに一時保存したり、ダイアログボックスを開く・レポートを印刷する・バックグラウンドプロセスを開始するなどの動作を実行したりします。 アクティブオブジェクトの種類は、 アクティブオブジェクトの種類は、 入力フィールド、コンボボックス、ドロップダウンリスト、ピクチャーボタンなど様々ですが、いずれもデータを表示したり、メモリに一時保存したり、ダイアログボックスを開く・レポートを印刷する・バックグラウンドプロセスを開始するなどの動作を実行したりします。
  • スタティックオブジェクト (線、枠、背景ピクチャー等) は一般的に、フォームのアピアランスやラベル、グラフィックインターフェースを設定するために使用されます。 アクティブオブジェクトと異なり、スタティックオブジェクトには変数や式が割り当てられません。 しかし、スタティックオブジェクトにダイナミックオブジェクトを挿入することは可能です。

オブジェクトの操作

4D フォームオブジェクトの追加や編集は次の方法でおこなえます:

  • フォームエディター: ツールバーからオブジェクトをフォーム上にドラッグ&ドロップします。 次に、プロパティリストでオブジェクトのプロパティを指定します。 次に、プロパティリストでオブジェクトのプロパティを指定します。

  • 4D ランゲージ: OBJECT DUPLICATE or OBJECT SET FONT STYLE などの、Objects (Forms) テーマのコマンドを使用することでフォームオブジェクトを作成し、定義することができます。

  • ダイナミックフォーム内の JSON コード: JSON を使ってプロパティを定義します。 type プロパティでオブジェクトタイプを定義し、提供されている他の プロパティ のうち必要なものを設定します。 次はボタンオブジェクトの例です: type プロパティでオブジェクトタイプを定義し、提供されている他の プロパティ のうち必要なものを設定します。 次はボタンオブジェクトの例です:

	{
"type": "button",
"style": "bevel",
"text": "OK",
"action": "Cancel",
"left": 60,
"top": 160,
"width": 100,
"height": 20
}

Accessing form objects using their name or their data source in the 4D language

Many commands handling form objects such as commands from Objects (Forms), List Box, or Styled Text themes share the same generic syntaxes described here:

COMMAND NAME( * ; *object* : Text { ; *additional parameters* } )
//or
COMMAND NAME( *object* : Variable, Field { ; *additional parameters* })

If you specify the * parameter, you indicate that object is the name of the object (a string). If you don't pass the *, you indicate that object is a field or a variable, i.e. its data source.

When using the object name, you can rely on the @ character within that name if you want to address several objects of the form in one call. The following table shows examples of object names you can specify to this command.

Object NamesObjects affected by the call
mainGroupBoxOnly the object mainGroupBox.
main@The objects whose name starts with “main”.
@GroupBoxThe objects whose name ends with “GroupBox”.
@グループ@The objects whose name contains “Group”.
main@BtnThe objects whose name starts with “main” and ends with “Btn”.
@All the objects present in the form.

Form object names can contain up 255 bytes, allowing you to define and apply custom naming rules, such as "xxxx_Button" or "xxx_Mac".

警告

You can configure the way the @ character is interpreted when it is included in a character string. This option affects the functioning of the form object commands.