Batching Slider messages
-
My Tool gets a lot of messages when using sliders or dragging on numeric fields in the AM. In the C++ SDK (2026) is there an approved or suggested way to detect when the interaction has finished so that I can defer any heavy calculations until then? In particular I would like to add just one Undo for the entire interaction.
Thanks.
-
Hey @SteveHill3D,
Thank you for reaching out to us. It depends a bit on what is your 'tool'. When it is a 'classic' tool, i.e., implemented as a
ToolDatawith aGeDialog, thenBFM_DRAGENDwould be the way to sort outBFM_ACTIONevents for a slider that are the final action of a drag event. When you search for the message symbolBFM_DRAGENDand its sibling symbolsBFM_DRAGSTARTandBFM_ACTION_INDRAGhere on the forum, you will find multiple code examples around the topic of sliders. I think there are also some examples in the C++ SDK.When your tool is a
DescriptionToolData, i.e., a node in disguise, then you cannot handle drag events yourself. Your tool should fire on its own only afterMSG_DESCRIPTION_POSTSETPARAMETERhas fired for your node, i.e., after the final value of a drag event for some slider has been set.Please have a look at our Support Procedures, we require users to post code for pretty much all questions, as it minimizes the guess work on our side. As for example me here writing about two cases.
Cheers,
Ferdinand -
Thanks for the reply. Sorry for the imprecision - it is difficult to know what information is relevant when starting out, and I was trying to be concise. I am currently deriving from DescriptionToolData. I tried using MSG_DESCRIPTION_POSTSETPARAMETER but I get those during dragging also and the flags in the message are always the same even at the end i.e. USERINTERACTION | INDRAG as reported by:
Bool MyTool::Message(BaseDocument *doc, BaseContainer &data, Int32 type, void *t_data) { if (type == MSG_DESCRIPTION_POSTSETPARAMETER) { auto ps = (DescriptionPostSetValue *)t_data; DiagnosticOutput("Post set @ @", ps->descid[0][0], ps->flags); } ... return SUPER::Message(doc, data, type, t_data); }Maybe I need to rethink and consider a ToolData basis.
Steve.
-
Hey @SteveHill3D,
it's okay, the start is always a bit chaotic. That snippet alone would have told me some things.
Yes, sorry,
MSG_DESCRIPTION_POSTSETPARAMETERis fired within the drag event (the parameter has still to be set). The final description event isMSG_DESCRIPTION_USERINTERACTION_END. But I still do not really understand what you are doing. What is triggering the updates? Just dragging one of the sliders will not update the tool in our edge cutter tool example (because it does not really implement the interactive mode that comes with description tools).So, the tool should either fire when you have keyboard or viewport inputs and implemented
MouseInputorKeyboardInput. When you click Apply, it should callDoCommand. You can of course hook intoMessageto react to all sorts of things (and that is indeed how you implement the interactive mode), but you message implies that your tool fires on your own. Which it should not.Cheers,
Ferdinand -
Thank you. MSG_DESCRIPTION_USERINTERACTION_END is just what was needed.