AddCallbackItem menu item, how to pass a variable

Discussions concerning programming of SOFTIMAGE©
Post Reply
Fabian
Posts: 14
Joined: 19 Nov 2014, 15:49

AddCallbackItem menu item, how to pass a variable

Post by Fabian » 05 Apr 2017, 15:47

Hi,
is there a way to pass a string from the menu item to the callback handler function. For dynamically created menu items I'd like to attach some information (directory path) that is passed from the menu item to the callback function. I've tried to abose the help string for this but for some reason I can't set .Help for submenu or callback items.

The only thing I've managed so far is to have a dictionary mapping based on the menu item lablel and having the callback function lookup from that based on in_ctxt.Source.Name in the callback function.

Thank you,
Fabian

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: AddCallbackItem menu item, how to pass a variable

Post by rray » 05 Apr 2017, 16:45

Hi
would be the only idea I have too, some dictionary or JS object that you could put in in_ctxt.UserData.
-rr
softimage resources section updated Jan 5th 2024

luceric
Posts: 1251
Joined: 22 Jun 2009, 00:08

Re: AddCallbackItem menu item, how to pass a variable

Post by luceric » 05 Apr 2017, 23:57

I don't remember how to do this, but another method is to generate the code of the callback on the fly.

It's something like you use "exec()" to generate the new function.

You would generate it a unique name, like "def my_callback_01():" and what it does is calls a common method you have with the parameter you need for it.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests