| Article | 70002771 |
| Type | HowTo |
| Product | Engine |
| Date Added | 10/7/2025 12:00:00 AM |
| Fixed | 11.5.1 (10/7/2025 12:00:00 AM) |
| Submitted by | Damian Nowosinski |
Summary
Use control key to switch between multi and single selection. When a command that wait for a user selection, like move copy etc. , we want to start a window selection only if the Control Key is pressed else assept only single entities under the left mouse down
Solution
Example code
VdDocument doc;//A predefine document
doc.ActionStart += Doc_ActionStart;
doc.ActionEnd += Doc_ActionEnd;
bool isselecting = false;//it is true when a user selection is started
private void Doc_ActionEnd(object sender, string actionName)
{
if (actionName == "CmdSelect") isselecting = false;
}
private void Doc_ActionStart(object sender, string actionName, ref bool cancel)
{
if (actionName == "CmdSelect") isselecting = true;
if (!isselecting || actionName != "BaseAction_ActionGetRectFromPointSelectDCS") return;//ActionGetRectFromPointSelectDCS is started by default when no entity is found uder the mouse down and a window selection started
//it is ActionGetRectFromPointSelectDCS inside CmdSelect
BaseAction action = doc.ActiveLayOut.OverAllActiveAction;//get the active action object which is a type of ActionGetRectFromPointSelectDCS
if (BaseAction.PressedKeyCode != Keys.Control) action.FinishAction(action);//if the Control key is not pressed then immediately finish the window select action
}
