On 01/07/2018 at 09:59, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R19
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
I was experimenting with a CommandData plugin and shortcuts (as sequel on previous question).
Registering a CommandData using the PLUGINFLAG_COMMAND_STICKY, according to the documentation I should be able to detect the user pressing the shortcut key, and releasing it.
In both cases CommandData::Execute would be called.
This, however, is only the case when the user keeps the shortcut pressed long enough.
If the shortcut is pressed shortly and released, only a single Execute is performed on the "down-stroke". The "up-stroke" (release) is never detected.
#include "c4d.h"
// Dummy IDs - for demonstration purposes only
#define COMMAND_PLUGIN_ID 1999999
Bool gShowWidget = FALSE;
class MyCommand : public CommandData
{
INSTANCEOF(MyCommand, CommandData)
public:
virtual Bool Execute(BaseDocument* doc);
};
Bool MyCommand::Execute(BaseDocument* doc)
{
gShowWidget = !gShowWidget;
String txt = gShowWidget ? "On" : "Off";
GePrint("Widget is " + txt);
return TRUE;
}
Bool RegisterMyCommand(void)
{
return RegisterCommandPlugin(COMMAND_PLUGIN_ID, "Testing", PLUGINFLAG_COMMAND_STICKY, AutoBitmap("icon.png"), "Test", NewObjClear(MyCommand));
}
// ====================================
// Plugin Main
// ====================================
Bool PluginStart(void)
{
RegisterMyCommand();
return TRUE;
}
void PluginEnd(void)
{
}
Bool PluginMessage(Int32 id, void * data)
{
switch (id) {
case C4DPL_INIT_SYS:
if (!resource.Init())
return FALSE;
return TRUE;
case C4DMSG_PRIORITY:
return TRUE;
case C4DPL_BUILDMENU:
break;
case C4DPL_ENDACTIVITY:
return TRUE;
}
return FALSE;
}