GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Collapse Current Group and Put the Selection Box on It

scripting

#1

I want to:

  1. collapse the group of the currently selected item;
  2. move the selection box to that group.

I got the first part working, but I could not locate a way to do the second. Is there any?

function OnClick(clickData)
{
	if (clickData.func.sourcetab.selected.count >= 1) {
		var cmd = clickData.func.command;
		cmd.SetModifier("noprogress");
		
		var current_group = clickData.func.sourcetab.selected(0).filegroup;
		
		if (current_group.collapsed) {
			var operation = "GROUPEXPAND";
		} else {
			var operation = "GROUPCOLLAPSE";
		}
		cmd.AddLine("Go " + operation + " \"" + current_group + "\"");
		cmd.Run();
	}
}

#2

We’ll add a command for this in the next update.

The following line will be what you’ll need to add:

cmd.AddLine("Select NOPATTERN GROUPNAME \"" + current_group + "\" SETFOCUS");


#3

Tried that line, it is not working. It opens the Advanced Selection dialog instead.

function OnClick(clickData)
{
	if (clickData.func.sourcetab.selected.count >= 1) {
		var cmd = clickData.func.command;
		//cmd.SetModifier("noprogress");
		
		var current_group = clickData.func.sourcetab.selected(0).filegroup;
		
		if (current_group.collapsed) {
			var operation = "GROUPEXPAND";
		} else {
			var operation = "GROUPCOLLAPSE";
		}
		cmd.AddLine("Go " + operation + " \"" + current_group + "\"");
		cmd.AddLine("Select NOPATTERN GROUPNAME \"" + current_group + "\" SETFOCUS");
		cmd.Run();
	}
}

#4

Your script works ok here. Have you installed the 12.7.5 beta?


#5

Yes, I am on 12.7.5 beta. The issues I mentioned in my other recent threads were fixed, so I guess a botched install isn’t the case.


#6

We reproduced the problem and a fix for this is on the way.