Howto trigger CommandData::GetState()



  • Hi,
    I have a GeUserArea where items are drawn. User can select one or more of these items.
    Next to this I have several actions, defined as CommandData derived plugins, which can each perform a specific action on the selected item(s). I am able to control the state of these CommandData icons, using GetState() to obtain information from my userarea and return the appropriate value to show the icon/menu-item enabled or disabled, checked or unchecked.

    Which message is actually responsible for triggering the CommandData::GetState()?
    As I need to trigger the GetState when an item is (de)selected in the userarea, so that the CommandData can check the userarea and decide to enable/disable the command.

    Thanks



  • Hello,

    I'm not sure if you are creating a customDataType + customGUI or only a customGUI. I'm also not sure where you are storing your data. I'm afraid you are storing your data in your GeUserArea witch is not a good place to.

    Your data should be stored in a BaseContainer. This BaseContainer can be stored in a tag, an object, the Document itself.

    I can still try to point to the right direction :

    You don't have to send a message to trigger directly the CommandData::GetState()

    There's an example that could help you in the sdk //sdk/source/gui/customdata_customgui.cpp or you can see the file on github

    You will see that the GeUserArea use SendParentMessage to tell the parent that something have changed.

    BaseContainer m(BFM_ACTION);
    m.SetInt32(BFM_ACTION_ID, GetId());
    SendParentMessage(m);
    

    The parent will catch this message and will send a message to its parent. (in the exemple, Bool
    ExampleCustomGUIDots::Command(Int32 id, const BaseContainer &msg))

    So at the end, Cinema4D will trigger what it need and GetState()

    Let me know if it's not clear.

    Cheers
    Manuel



  • @m_magalhaes
    Sorry, I didn't explain well enough.

    I have a CommandData derived plugin with a GeDialog. The only gadget of the dialog is a GeUserArea.
    In the userarea I draw items, which the user can "select" by simply left-mouse-clicking in the bounding box of the item.

    Next I have several other CommandData derived plugins.
    These are used to activate actions on the selected items.
    What I try to perform is to enable/disable these "action" depending on the selected item in the userarea.

    If I implement the SendParentMessage in the userarea (on successful item selection), it triggers the GeDialog::Command, which then triggers its parent with another SendParentMessage. But the parent of the GeDialog is its CommandData, while I need to trigger the "action" CommandDatas instead, in order to update their state.



  • hello,

    In this context you can use EventAdd()

    Cheers
    Manuel



  • I had noticed that the EVMSG_CHANGE was actually triggering the GetState of my CommandDatas, but I was wondering if a different approach was available.
    Still, I am OK with the EventAdd() solution. Thanks.