グループとバックグラウンド(コントロールの操作と共用)
Groups, Revolution's most versatile object type, are used for several purposes: radio button clusters; menu bars; and as backgrounds for displaying sets of objects that are shared between cards. Groups can also be used for creating a simple card and stack database, by holding fields that contain a different record on each card. For more details on using fields in this way, see the section on the Field Object.
レヴォルーションで最も多目的に使用できるオブジェクト形式であるグループは、様々な目的に使用できます:ラジヲ・ボタン群;メニュー・バー;更には、カード間で共有される一連のオブジェクトを表示するバックグラウンドとして等です。またグループは、簡単なカードの作成やカード毎に異なるレコードを持つフィールドをもつスタック・データベースの作成などにも使うことができます。フィールドのこうした使い方に関する詳細は、Field Objectセクションをご覧下さい。
What Is a Group?
グループとは何か
A group is a single object that holds a set of objects. You group objects by selecting the controls you want to include in the group, then using the group command or choosing Object –> Group Selected.
グループは複数のオブジェクトからなる単一のオブジェクトです。グループに含めたいコントロールを選択し、次にgroupコマンドかメニューからObject –> Group Selectedを選択してオブジェクトをグループ化します。
Once you've created the group, it becomes an object in its own right. You can select, copy, move, and resize the group, and all the objects in the group come with it. The objects in the group maintain their own identities, and you can add objects to the group or delete them, but the objects are owned by the group instead of the card.
一旦グループが作成されると、グループは独立したオブジェクトとして扱われます。その為、グループを選択し、コピーし、移動し、拡大縮小でき、グループ内の全てのオブジェクトもそうした操作に追随します。とは言え、グループ内の各オブジェクトは尚独立した存在であり、グループ内に新たなオブジェクトを追加したり、削除したりできますが、あくまでもグループ内のオブジェクトはカードではなくグループに属すことになります。
A group has its own properties and its own script. Groups can be any size, can be shown or hidden, and can be moved to any location in the stack window, just like any other control. Like other controls, groups can be layered in any order with the other controls on the card. Groups can also display a border around a set of objects.
グループは独自のプロパティとスクリプトを持っています。グループは、他のコントロール同様、どのような大きさにもできますし、表示することも非表示にすることもでき、スタックのウインドウ内のどの位置にも配置することができます。また他のコントロール同様、カード上の他のコントロールと合わせてどんな階層(レイヤー)にも配置できます。グループに組み合わされたオブジェクト全体の周囲に境界線を表示させることも可能です。
Figure 38 – Group of radio buttons with group title and border
図38 ー グループのタイトルと境界線をもつラジヲ・ボタンのグループ
Unlike other controls, however, groups can appear on more than one card. You place a group on a card using the place command or the Place Group submenu in the Object menu.
処が他のコントロールとは異なり、グループは複数のカード上に表示することができます。placeコマンドやオブジェクト・メニューのサブメニューであるPlace Groupを使ってカード上にグループを設定できます。
Important: A group that is shared between cards appears at the same location on each card. A change made to the position of a shared group on one card is reflected on all the other cards that share the group.
重要: カード間で共有されているグループは、各カード上の全く同じ位置に表示されます。或るカード上の共有グループの位置を変更すると、その共有グループの表示位置は他の全てのカード上でも変更した位置になってしまいます。
Groups and Backgrounds
グループとバックグラウンド
Both the term group and the term background can be used to refer to groups. The terms are interchangeable in some circumstances and mean different things in others. The differences are explained in more detail below.
「グループ」と「バックグラウンド」の二つの術語は伴にグループに関して言及する時に使われます。この二つの術語は、ある場面では同義語として、ある場面では全く異なるものとして扱われます。このような使い方の違いについては、以下で詳しく記述していきます。
In general, the term group refers to groups that are placed on a card, while the term background refers to all the groups in a stack that are available for use as backgrounds (see below).
The expression the number of groups evaluates to the number of groups on the current card. The expression the number of backgrounds evaluates to the number of background groups in the current stack, including groups that are not placed on the current card.
通常「group」という語は、カードに置かれたグループを指しており、また「background」は、(後述する)バックグラウンドとして使用可能なスタックにある全てのグループを指しています。
the number of groupsという表現式は、現在表示しているカードにあるグループの総数を表し、the number of backgroundsは現在使用しているスタックにあるバックグラウンド・グループの総数を表していて、現在表示しているカード以外のカードに置かれているグループも含めた数になります。
Tip: When you refer to a group by number, if you use the word group, the number is interpreted as referring to the groups on the referenced card, in order by layer. If you use the word background, the number is interpreted as referring to the groups in the stack, in the order of their creation.
For example, the expression the name of group 1 evaluates to the name of the lowest-layered group on the current card, while the expression the name of background 1 evaluates to the name of the first group that was created in the stack--whether or not that particular group is placed on the current card, or appears on any card at all.
秘訣: あるグループを番号で参照する時に、groupという語を使うと、その番号は参照したカードにあるグループのレイヤー順として扱われます。backgroundという語を使うと、その番号はスタックにあるグループの作成順として扱われます。
例えば、the name of group 1という表現式では現在のカードにある最下層のグループの名前を値として返すのに対し、表現式the name of background 1では現在のスタックで一番最初に作製されたグループの名前を値として返します;さらにこの場合には、その表現式で参照されるグループが現在のカード上に存在するか否か、また全てのカード上で表示されているか否かにかわらず、表現式で参照されるグループの名前が値として返されるのです。
The term background can be also used to refer to the set of cards that share a particular group. The following statement goes to the third card on which the group named "Navigation" is placed:
go card 3 of background "Navigation"
「background」という語は、更に特定のグループを共有するカードの組を参照するのに使われます。次のステートメントでは、グループ名「Navigation」の置かれた3番目のカードに移動します。
Nested Groups
入れ子になったグループ
Revolution supports nested groups (one group containing another). Since a group is itself a control, it can be contained in another group.
レヴォルーションでは、(グループ内にグループを含む様な)入れ子になったグループを扱うことができます。これはグループはそれ自身が一つのコントロールだからで、それ故他のグループに属することができるのです。
Creating a nested group is just like creating a group: select the controls you want to group (including the existing group), then choose Object -> Group Selected. The existing group is now a member of the new group.
入れ子になったグループを作るのは、まさにグループを作るのと同じです:(既にあるグループを含め)コントロールを選択し、メニューからObject -> Group Selectedを選ぶだけです。それだけで、既存のグループは新たに作製したグループに含められます。
Selecting and Editing Groups
グループの選択と編集
To select a group, simply click on one of the objects that is contained within it. This will select the group.
グループを選択するのは、単にグループに含まれるオブジェクトの一つをクリックするだけです。これでグループが選択されます。
If you want to select an object within the group, instead of the group itself, there are two ways to do so. You can turn on the Select Grouped option on the toolbar or in Edit -> Select Grouped Controls. This causes groups to be ignored when selecting objects, allowing you to select objects inside a group as if the group didn’t exist. You can enter this mode by script by toggling the selectGroupedControls global property.
グループ全体ではなく、グループに属しているオブジェクトの一つを選択するには、二つの方法があります。ツールバー上のSelect Groupedオプションをオンにするか、Edit -> Select Grouped Controlsを選択します。この操作で、オブジェクト選択時にグループが選択されることが無くなり、まるでグループなど存在しないが如く、グループ内のオブジェクトのどれでも単独に選択することができるようになります。スクリプトでグローバル・プロパティselectGroupedControlsを切り替えることでも、このモードにはいることができます。
Alternatively you can go into edit group mode, a special mode that only displays the objects within that group. Select the group, then press Edit Group on the toolbar or choose Object -> Edit Group. When you have finished, choose Object -> Stop Editing Group. You can toggle this mode programmatically by using the commands start editing and stop editing.
もう一つの方法は、グループの編集モードを使うことです。このモードでは、選択したグループにあるオブジェクトのみを表示する特別なモードです。グループを選択し、ツールバーのEdit Groupをクリックするか、Object -> Edit Groupを選択します。終了したら、Object -> Stop Editing Groupを選択します。プログラムを使ってこのモードに入ったり出たりするには、start editingコマンドとstop editingコマンドを使います。
Tip: If a group's border has been set, an outline appears at the group's edges. However, clicking within or on the border does not select the group. To select the group, you must click one of its controls.
秘訣: グループの境界線が設定されていると、グループの周囲に輪郭線が表示されます。しかし、輪郭線の内側や輪郭線をのものをクリックしてもグループは選択されません。グループの選択は、グループ内のコントロールの一つをクリックします。
Placing and Removing Backgrounds
バックグラウンドの設置と削除
Once you create a group, you can display it on any or all cards in the stack. First, ensure that the group’s Behave as Background option has been set in the Inspector. Then navigate to the card you want to place the group on and choose Object -> Place Group to place an instance of a particular group on the current card. You can control these features from script by using the backgroundBehavior property and place command.
一旦グループが作られると、スタック内のどのカードにも、或いは全てのカードにも、バックグラウンドを表示させることができます。まず、インスペクタでグループのバックグラウンドとして振る舞う(Behave as Background)オプションが選択されているかを確認します。次に、グループを配置したいカードに移動し、現在のカードの指定したグループのインスタンス(継承)を配置するためにObject -> Place Groupを選択します。backgroundBehaviorプロパティとplaceコマンドを使って、こうした機能をスクリプトで操作することもできます。
Note: When you create a new card, if there are any groups on the current card whose Behave as Background has been set, they are automatically placed on the new card. To make it easy for all the cards in a stack to share a single group, create the group on the first card and set this property to true, before you create any other cards.
注釈: 新規カードを作るときに、現在のカードにバックグラウンドとして振る舞うグループが存在すると、そうしたグループは新規カードに自動的に配置されます。単一のグループを共有するカードをスタックに簡単に作製するには、スタックの最初のカードにグループを作製し、そのグループのバックグラウンドとして振る舞うプロパティを真に設定し、その後新たなカードを作製していきます。
To remove a group from the current card without deleting it from the stack select the group and choose Object -> Remove Group. The group disappears from the current card, but it's still placed on any other cards that share the group. You can remove a group by script using the remove command.
現在のカードをスタックから削除せずに、カードに配置したグループだけを削除するには、グループを選択し、Object -> Remove Groupを実行します。すると現在のカードからそのグループは消えてしまいますが、そのグループを共有している他のカード上には以前として配置されたままになります。あるグループをスクリプトで削除するには、removeコマンドを使います。
Tip: You can use the start editing command from the Message Box to edit a group that has not been placed on any card. Since the group is not on any card, you must refer to it using the term "background" instead of the term "group".
秘訣: メッセージ・ボックスからstart editingコマンドを使って、まだどのカード上にも配置されていないグループを編集することができます。グループがどのカードにも配置されていないため、そのグループを参照する用語(ターム)には「group」のかわりに「background」を使う必要があります。
You can completely delete a group in the same way as you delete any other object, by selecting the group and choose Edit -> Clear or pressing backspace.
他のオブジェクトの削除と同じ方法でグループを完全に削除することができます。まずグループを選択し、次にEdit -> Clearを選ぶかバックスペース・キーを押します。
Important: Deleting a background group removes it from all the cards it appears on, and from the stack itself.
重要: バックグラウンド・グループの削除は、そのグループが表示される全てのカードからと同時にスタックからもそのグループを削除することになります。
To dissolve a group back into its component controls, select the group and choose Object -> Ungroup. You can ungroup a group by script using the ungroup command.
Ungrouping deletes the group object and its properties (including its script) from the stack, but does not delete the controls in it. Instead, they become card controls of the current card. The ontrols disappear from all other cards the group is on.
グループを解除して各コントロールを独立したものに戻すには、まず対象となるグループを選び、次にObject -> Ungroupを実行します。ungroupコマンドを使ってスクリプトによるグループの解除もできます。
グループの解除は、グループというオブジェクトのスタックからの削除であり、(スクリプトを含む)グループとしてのプロパティのスタックからの削除でもありますが、グループに含まれていた各コントロールが削除されるわけではありません。それらは一切削除されることなく、新たに現在のカードに属するカードのコントロールに生まれ変わるのです。さらに、これらのコントロールは、現在のカード以外の全てのカードからは消えてなくなります。
Note: If you ungroup a group, then select the controls and regroup them before leaving the current card, the group is restored as it was. However, leaving the current card makes the ungrouping permanent and deletes the group from all other cards it was on.
注釈: グループを解除し、次にコントロールを選択し、現在のカードを離れる前に再度グループ化すると、グループは以前あった通りに復元されます。ですが、一旦現在のカードを離れてしまうと、グループの解除は復元されず、グループが存在していた他の全てのカードからグループとその構成物であるコントロールは削除されてしまいます。
Groups and the Message Path
グループとメッセージ・パス
For details on how groups and backgrounds fit into the Message Path, see the section on Groups, Backgrounds & The Message Path, below.
グループとバックグラウンドがメッセージ・パス内でどのように機能するかの詳細は、以下に述べるn Groups, Backgrounds & The Message Pathセクションをご覧下さい。