Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Sticky key not being sticky

    Scheduled Pinned Locked Moved Bugs
    4 Posts 0 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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;  
      }  
      
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 03/07/2018 at 00:46, xxxxxxxx wrote:

        Hi C4D,

        thanks for making us aware.

        I filled a bug report.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post