Sticky key not being sticky
- 
 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; }
- 
 On 03/07/2018 at 00:46, xxxxxxxx wrote: Hi C4D, thanks for making us aware. I filled a bug report. 
- 
 On 03/07/2018 at 09:45, xxxxxxxx wrote: Thanks for confirming. I suppose there's no workaround other than to use a SceneHook and check for keystrokes in KeyboardInput ... as has been mentioned by Andreas here 
- 
 On 04/07/2018 at 00:27, xxxxxxxx wrote: Hi C4DS, You are right, SceneHook or a ToolData depending on the context is the way to go. 
 But as you already discover they got some limitation.Hope it's a working workaround for you. 
 Cheers,
 Maxime