Groupを解除せずにGroupの内容を操作

create img "MU1" in group "Markers"

グループ化したボタンやフィールド、imgやgrcをグループから出したり、グループに新たにimgやgrcを追加するには、いったんグループを解除してもう一度それらをグループ化しなければならないと思っていました。過去のRunRevのログにもそのように書かれています。

しかし、これをスクリプトで実行すると若干のタイムラグがPen3あたりだと生ずるのです。しかも、グループに含まれていたアイテムを何らかの方法で記録しておかなければ再グループできません。
上記のスクリプトで新規のアイテムをグループの中に瞬時に作成することができます。このようにして作られたエレメント img "MU1"は空ですから、その後に何らかのスクリプトを書いて内容を作る必要があります。

delete img "MU1" of group "Markers"

削除も同じ方法でできます。しかし、削除の時はofでなければならないようです。inを使うとグループごと削除されました。(v2.61, build108)


次は、エレメントを直接既存のグループに移動する方法です。(2016年8月14日)
以下のような構成の場合("meat"グループに"chicken"と"beef"があり、"fish"と"fred"はグループに属さない)、

Layer | Control
------------------------------------------
1     button "fish"
2     group "meat"
3       button "chicken"
4       button "beef"
5     button "fred"

次のように書くことで、"fish"を"meat"のグループに加えることができます。(v5.5.0 build1479)

set the relayerGroupedControls to true
set the layer of btn "fish" to the layer of grp "meat"
set the relayerGroupedControls to false

この"fish"を"meat"のグループから出すには次のように書きます。

set the relayerGroupedControls to true
set the layer of btn "fish" to 1
set the relayerGroupedControls to false


その他(2005年8月10日)

オンラインマニュアルによれば、グループに名前をつけるにはいったんエレメントをグループ化した後でthe last groupなどによってグループを指定して名前をつけるように書いてありますが、次のスクリプトで、いきなりグループを作り名前をつけることができます。

create group "Markers"

このようにして作られたグループは空のグループです。しかし、次のように書くことはできません。

create group "Markers" of cd "Units" of stack "Main"

しかし、次のようなことはできてしまいます。

get the number of images of group "markers" of cd "units"


検索したところ、次のように既存のオブジェクトをグループの中にコピーすることもできるようです。


Rick,

Simply use the following to get an object that is not in a group, into a
group.

copy graphic "oval" to group "groupNameHere"

then you need to delete the original control that is not in the group.

-Mark Talluto

On Wednesday, January 16, 2002, at 08:30 AM, Rick Rice wrote:

> How do you add objects to a group?
> I have an image which is 4 times larger in area than the screen
> window.
> The image contains various cells. I want to draw an oval around various
> cells
> and then group the ovals and image so when the image is moved the ovals
> move
> as well and remain around the cell I drew it around. Now here's the
> problem. I
> can draw the ovals and group then with the image but then I have to
> move the
> image so a different area is in the window I run into a problem. I can
> draw
> ovals around the cells in the new area but how do I group these new
> ovals with
> the previous group?
> Hope this description makes sense.
> Thanks
>
> Rick


 

スクリプトのStart EditingStop Editingは、以下のような時のためにあるみたいです。

Re: Adding objects to groups

On Fri, 30 Nov 2001 16:02:19
Ben Rubinstein wrote in part:

>Jeanne,

>I've never whinged about lack of information on how to create objects in an
>existing group - it was how to add an existing object to an existing group
>that I couldn't find information on.

Ben, from this post, I'm not sure whether you're just commenting on a lack of
documentation, or whether you haven't yet found a way to actually do the task.

Here's how I do it:

1. Copy the existing object to the clipboard.

2. Select the group you want to add the object to.

3. Select *Edit Group* in the Object menu.

4. Paste the object from the clipboard (it now becomes part of the group).

5. Select *Stop Editing Group* in the Object menu.

6. Delete the original object.


Ted


レイヤーを動かしてグループ化することもできるようです。

I believe the trick is something like this:

     set the relayerGroupedControls to true
     set the layer of btn 1 to the layer of group 1

Brian


Here's my control outlilne:

Layer | Control
------------------------------------------
1   group "food"
2     group "meat"
3       button "chicken"
4       button "beef"
5     button "fred"
6     group "fruit"
7       button "apple"
8       button "orange"

If I execute the following statement:

     set the relayerGroupedControls to true
     set the layer of group "fruit" to 5
     set the relayerGroupedControls to false

All of a sudden, group "fruit" is now a sub group of group "meat" and looks
like:

Layer | Control
------------------------------------------
1   group "food"
2     group "meat"
3       button "chicken"
4       button "beef"
5       group "fruit"
6         button "apple"
7         button "orange"
8     button "fred"


Anyone know how to get it to look like:

Layer | Control
------------------------------------------
1   group "food"
2     group "meat"
3       button "chicken"
4       button "beef"
5     group "fruit"
6       button "apple"
7       button "orange"
8     button "fred"


Hi Chip - I've struggled with this before and from memory you can't usually
do it in a single step. You essentially have to reorder objects or groups
(by moving them to the top of the group) in such a way that the object/group
you're interested in is forced down through the layers into the desired
position. So in your example I think you would...

     1. set the layer of btn "fred" to 2
     2. set the layer of grp "fruit" to 2
     3. set the layer of grp "meat" to 2

...ending up with your desired layering sequence.

HTH,

Terry...


Well, I figured it out..and boy is it simple..
When relayering a control, you first should find out if it is contained
within a group. If so then start editing the group. Identify the control you
wanted to move then simply:

     get the layer of tControlID
     set the layer of tControlID to it + 1 (moves it up one level)
     set the layer of tControlID to it - 1 (moves it down one level)
     set the layer of tControlID to top (moves it the the top of parent grp)
     set the layer of tConrtolID to bottom (moves it the the bottom of parent grp)

Note-- I said 'one level' not one layer. This is an important distinction.
The Rev engine already knows how to move groups around relative to each
other so setting a groups layer to one less than current will automatically
'skip' over all other controls owned by a lower group.

Pretty simple. I was focussed on setting layer numbers. This is much
easier-- and the trick is to work inside the edit group command. Also Ken
Ray's function is important as well-- as you can't get a unique long owner
for a control which is part of a group.

function stsLongOwnerID pObjID,pOpt_NumLevels
  if pOpt_NumLevels = "" then put 1 into tNum
  else put pOpt_NumLevels into tNum
  if word ((4*tNum)+1) of pObjID is among the items of "group,card" then
     delete word 1 to (4*tNum) of pObjID
  end if
  return pObjID
end stsLongOwnerID

-Chipp