Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    GeUserArea keyboard focus

    SDK Help
    0
    14
    1.1k
    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
      Helper
      last edited by

      On 24/08/2015 at 02:27, xxxxxxxx wrote:

      here is what I do:

        
      static Bool InvokeCommandCall(GeDialog* dialog, Int32 id) {
          BaseContainer actionmsg(BFM_ACTION), actionresult;
          actionmsg.SetInt32(BFM_ACTION_ID, id);
          return dialog->Message(actionmsg, actionresult);
      }  
      

      in iCustomGui subclass:

        
          virtual Bool Command(Int32 id, const BaseContainer& msg) {
              if (id == COMMANDMSG_VALUECHANGED) {
                  SendValueChanged(this, msg);
              }
              return TRUE;
          }  
      
        
      static Bool SendValueChanged(iCustomGui* dlg, BaseContainer msg) {
          msg.SetInt32(BFM_ACTION_ID, dlg->GetId());
          msg.RemoveData(BFM_ACTION_VALUE);	
          msg.SetData(BFM_ACTION_VALUE, dlg->GetData().GetValue());
          //GePrint("just msg " + String::IntToString((static_cast<iSnodeDataType*> (msg.GetData(BFM_ACTION_VALUE).GetCustomDataType(SEVENPHOTONS_NODE_CUSTOMDATATYPE)))->count));
      	return dlg->SendParentMessage(msg);
      }  
      

      which is simply updating my CustomDataType members, so if user interacts with GeUserArea,  InvokeCommandCall()  is the update function.

      if I remove  InvokeCommandCall()  , there is a delay, but it works without a problem, what should I do?

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

        On 24/08/2015 at 09:13, xxxxxxxx wrote:

        Hello,

        why are you sending a message in InvokeCommandCall() and then again with SendParentMessage()? Typically one uses SendParentMessage() to inform the parent dialog that something changed.  See the example on GitHub.

        Best wishes,
        Sebastian

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

          On 24/08/2015 at 10:39, xxxxxxxx wrote:

          I see, but the problem remains "I removed all calls to SendParentMessage(), all calls now are InvokeCommandCall()"

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

            On 25/08/2015 at 00:07, xxxxxxxx wrote:

            Hello,

            actually I would have suggested to remove that InvokeCommandCall() stuff and just send the SendParentMessage() to react accordingly when you catch that message.

            Best wishes,
            Sebastian

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

              On 25/08/2015 at 04:18, xxxxxxxx wrote:

              I will try, will reply soon with an update if it worked or not, thanks Sebastian.

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

                On 28/12/2015 at 18:39, xxxxxxxx wrote:

                Hi Sebastian,
                I know that was a little old, but I reworked the code and did many tests to see where the problem is.
                now what I can confirm: (attached a piece of the code..)

                  
                Bool SNodeUserArea::InputEvent(const BaseContainer& msg)
                {
                	Int32 dev = msg.GetInt32(BFM_INPUT_DEVICE);
                	Int32 chn = msg.GetInt32(BFM_INPUT_CHANNEL);
                	GePrint("any event!!");
                  
                	if (dev == BFM_INPUT_KEYBOARD)
                	{
                		GePrint("any key is pressed");
                		if(chn == KEY_DELETE)
                		{
                			if (!selection)
                				return true;
                  
                			BaseContainer actionk(BFM_ACTION);
                			actionk.SetInt32(BFM_ACTION_ID, GetId());
                			actionk.SetInt32(BFM_ACTION_VALUE, 0);
                			actionk.SetInt32(BFM_ACTION_UPDATE, true);
                			
                			removeSelectedNodes();
                			removeSelectedWires();
                			//InvokeCommandCall(GetDialog(), COMMANDMSG_VALUECHANGED, actionk);
                			SendParentMessage(actionk);
                			return true;
                		}
                	}  
                ......
                

                the problem is:
                after a mouse click "for example selecting a node in my userarea" , this changes the data of my CustomDataType, once this is done, the focus is gone!

                so next keyboard hit is missing "the whole InputEvent() is not called at all!" , so I have to click again.
                I also tested it with your example, your example works fine!, the only difference that I see is: in many cases I may send multiple parent messages... "is this a problem?"

                though I hacked around it, not sure if this is fine or not "you may tell " , I set:
                action.SetInt32(BFM_ACTION_UPDATE, true);

                this forced it to work! , so if this is fine you can consider this solved or suggest a better alternative

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

                  On 30/12/2015 at 14:33, xxxxxxxx wrote:

                  ok I found a pitfall!!, action.SetInt32(BFM_ACTION_UPDATE, true); actually updates immediatly BUT ignores the data change update "so the GeUserArea updates, but the internal data doesn't get a refresh "as this user area can be seen in multiple object managers, I see it only updating in 1 location when  action.SetInt32(BFM_ACTION_UPDATE, true); is active!"

                  on the other hand without this line, it got the keyboard delay focus, ideas?

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

                    On 31/12/2015 at 04:55, xxxxxxxx wrote:

                    Hi Mohamed,

                    Sorry for my late reply.
                    Sebastian will be back next week and I'm sure he'll be able to give you feedback and ideas for your problem.

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

                      On 04/01/2016 at 02:07, xxxxxxxx wrote:

                      Hello Mohamed,

                      your last posts are a little bit confusing. Can you post your current code of all relevant classes and functions?

                      Best wishes,
                      Sebastian

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

                        On 04/01/2016 at 04:44, xxxxxxxx wrote:

                        Hi Sebastian,

                        I guess the functions are getting delayed due to heavy processing "when the MatPreview is rendering the this problem happens!".

                        so I guess it is a wait for event loop that get ignored due to thread being busy in rendering.
                        but the problem as I posted, and the code is quite complex!! "more than 7k lines../+ I can't strip it ".

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

                          On 04/01/2016 at 09:10, xxxxxxxx wrote:

                          Hello,

                          I do not understand how material preview rendering is related to this thread. Without more specific information I don't think it is possible to give more help.

                          Best wishes,
                          Sebastian

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

                            On 05/01/2016 at 05:05, xxxxxxxx wrote:

                            He Sebastian,

                            it is a long story "this GeUserArea is a custom gui for a custom data type inside my MaterialData plugin".
                            but I tested when rendering is off too, it didn't work for unknown reason, I guess I will accept the result anyway.

                            you can consider this solved/closed.

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