Multiple selection inputs

Multiple selection inputs

p_krola
Enthusiast Enthusiast
455 Views
4 Replies
Message 1 of 5

Multiple selection inputs

p_krola
Enthusiast
Enthusiast

My Add in has two SelectionInputs. I have a problem checking which SelectionInput has been selected. How do I use activeInput ()? 

 

class MySelectHandler : public SelectionEventHandler
{
public:
	void notify(const Ptr<SelectionEventArgs>& eventArgs) override
	{
		if (!eventArgs)
			return;
		Ptr<Selection> selection = eventArgs->selection();
		if (!checkReturn(selection))
			return;


		// Get the value of the property.
		Ptr<SelectionCommandInput> propertyValue = selection->activeInput();


		

 

0 Likes
456 Views
4 Replies
Replies (4)
Message 2 of 5

Jorge_Jaramillo
Collaborator
Collaborator

Hi @p_krola ,

 

You can get the ID of the commandInput that fires the event with the id() property like so:

 

selection->activeInput()->id()

 

It returns a string.

 

Regards,
Jorge

 

0 Likes
Message 3 of 5

p_krola
Enthusiast
Enthusiast

The function at SelectionEventHandler generates an error:

_app->log(selection->activeInput()->id());
E0135 class "adsk::core::Selection" has no member "activeInput"

I can get inputId from InputChangedEventHandler, but that doesn't solve my problem. 

Ptr<CommandInput> changedInput = eventArgs->input();
std::string activeInput = changedInput->id();

 

0 Likes
Message 4 of 5

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I made a mistake in the previous answer.

It is like so:

 

Ptr<SelectionCommandInput> cmdInput = eventArgs->activeInput();
string id = cmdInput->id()

 

 

Lets try it.

 

Regards,
Jorge

0 Likes
Message 5 of 5

BrianEkins
Mentor
Mentor

I also recently ran into this problem. It seems there's a bug with the activeInput property. The workaround I ended up using is to check the hasFocus property of each of the SelectionCommandInput objects on my dialog. The one where this is true is the one that they are using.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes