SOLVED Change LONG_CYCLE selected Item.

hello,

You can set the default value you want in your Init function.
In any case, the Cycle will show the value corresponding to the value of the parameter.

#define MY_CYCLE_ID 1000

class DefaultCycleValue : public ObjectData
{
	INSTANCEOF(DefaultCycleValue, ObjectData)
public:

	virtual Bool Init(GeListNode *node)
	{
		// set the parameter the value we want, the Custom GUI will show the corresponding line in the box.
		node->SetParameter(DescID(MY_CYCLE_ID), GeData(1), DESCFLAGS_SET::NONE);
		return true;
	};

	virtual Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags) override
	{
	
		if (!description->LoadDescription(node->GetType()))
			return false;

		const DescID* singleid = description->GetSingleDescID();
		const DescID cid = DescLevel(MY_CYCLE_ID, DTYPE_LONG, 0);

		if (!singleid || cid.IsPartOf(*singleid, nullptr))
		{

			// add the parameter as long
			BaseContainer bc = GetCustomDataTypeDefault(DTYPE_LONG);

			// set the custom GUI to a cycle.
			bc.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_CYCLE);
			bc.SetString(DESC_NAME, "Long Cycle"_s);
			bc.SetInt32(DESC_SCALEH, 1);

			// cycle elements
			BaseContainer items;
			items.SetString(0, String("Item 0"));
			items.SetString(1, String("Item 1"));
			items.SetString(2, String("Item 2"));

			bc.SetContainer(DESC_CYCLE, items);

			// icons
			BaseContainer icons;
			icons.SetInt32(0, IDM_COPY);
			icons.SetInt32(1, IDM_CUT);
			icons.SetInt32(2, IDM_DELETE);

			bc.SetContainer(DESC_CYCLEICONS, icons);


			description->SetParameter(cid, bc, ID_OBJECTPROPERTIES);
		}

		flags |= DESCFLAGS_DESC::LOADED;

		return SUPER::GetDDescription(node, description, flags);
	};


	static NodeData *Alloc() { return NewObjClear(DefaultCycleValue); }
};

Cheers
Manuel

Thank you @m_magalhaes

This post is deleted!

Everything goes fine until the point I want to change the selected item. Assume that I have the following code, the Item with id 0 will be selected by default. Is there any way that I can change this? Like after a specific action the Item 1 will be selected?
event to determine when the selected item in the ListBox is changed.

hello @HectorSmallwood

@HectorSmallwood said in Change LONG_CYCLE selected Item.:

Assume that I have the following code, the Item with id 0 will be selected by default. Is there any way that I can change this? Like after a specific action the Item 1 will be selected?

That's exactly what the code is doing in the Init() function using SetParameter(). You change the value of the parameter, the UI show the item with that value in the list. So by default the parameter value is 1 so the UI show the item with the value 1 "Item 1"

If you want to change the item somewhere else, same thing just change the value of the parameter, the ui will follow.

node->SetParameter(DescID(MY_CYCLE_ID), GeData(1), DESCFLAGS_SET::NONE);

I'am adding an answer here as it is a related. But for your second question if the answer doesn't fit your need, please open a new thread and post your question in a new thread. That will help us to keep things organized.

@HectorSmallwood said in Change LONG_CYCLE selected Item.:

event to determine when the selected item in the ListBox is changed.

If i understand the question, you have to check for MSG_DESCRIPTION_CHECKUPDATE message type in the Message() function as follow.

virtual Bool Message(GeListNode* node, Int32 type, void* data) override
	{
		switch (type)
		{
			case MSG_DESCRIPTION_CHECKUPDATE :
			{
				DescriptionCheckUpdate* dcu = static_cast<DescriptionCheckUpdate*>(data);
				if (dcu == nullptr)
					return true;

				maxon::Int32 id = (*(dcu->descid))[0].id;
				if (id == MY_CYCLE_ID)
				{
					DiagnosticOutput("Cycle have been changed");
						// ... do Something
				}
				break;
			}
		}
		return true;
	};

Cheers
Manuel

This post is deleted!

Am I the only one who sees three posts in this thread defaced by insertions of spam into a valid post?

yesterday I saw 2 small triangles which i didn't unfold .... today they are gone... addblocker at work ?

hi,

thanks for pointing those spam. I cleaned them

Cheers,
Manuel

Thanks for guiding

Regards,
Folexin