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

    Mouse Over...

    SDK Help
    0
    5
    473
    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 09/04/2013 at 00:32, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R14 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi Folks,

      I'm trying to get the co-ords of the mouse when it's over my UserArea in a dialog, without having to press a button. I was under the impression that BFM_INPUT_X would retrieve this, but it only seems to be working on mouse button downs. An old thread (2005 I think) I read suggested that it should be working regardless of the mouse buttons, but I'm not finding that.

      It may be related to another issue I'm having, but I'll wait to see if I get a response here before opening that can of worms...

      How do I get the plain old position of the mouse without having an input state?

      WP.

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

        On 09/04/2013 at 02:56, xxxxxxxx wrote:

        Hi,

        To get the mouse coordinates of the mouse just while moving it you have to filter BFM_GETCURSORINFO message.
        InputEvent() is useless in this case because it's only called when a keyboard key or mouse button is pressed.

        LONG MyUserArea::Message(const BaseContainer &msg,BaseContainer &result)
        {
            switch (msg.GetId())
            {
                case BFM_GETCURSORINFO:
                    LONG mouseX = msg.GetLong(BFM_DRAG_SCREENX);
                    LONG mouseY = msg.GetLong(BFM_DRAG_SCREENY);
                    if (Screen2Local(&mouseX, &mouseY))
                        GePrint(LongToString(mouseX) + ", " + LongToString(mouseY));
                    break;
            }
          
            return SUPER::Message(msg, result);
        }
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 09/04/2013 at 03:45, xxxxxxxx wrote:

          Ah - thanks Yannick. I was experimenting with BFM_GETCURSORINFO but I was then calling the InputEvent function from there instead of getting them while in the message function...

          I'm getting correct coordinates now. Thankyou.

          WP.

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

            On 13/04/2013 at 20:40, xxxxxxxx wrote:

            There seems to be an issue with this. My mouse X and Y coordinate values won't update if I put a while loop in the message. Example below:

              
                          case BFM_GETCURSORINFO:   
                           {   
                                     BaseContainer bc;   
                                    LONG mX = msg.GetLong(BFM_DRAG_SCREENX);   
                                    LONG mY = msg.GetLong(BFM_DRAG_SCREENY);   
                                    Screen2Local(&mX;,&mY;);   
                                     LONG Xs = 40;   
                                     LONG Yl = 40;   
                                     while(mX >= Xs-10 && mX <= Xs+10 && mY >= Yl+10 && mY <= Yl-10)   
                                  {   
                                          GeShowMouse(MOUSE_ARROW_H);   
                                          GePrint("Looping..");   
                                         mX = msg.GetLong(BFM_DRAG_SCREENX);    // this is an issue, because BFM_DRAG_SCREENX/Y is NOT refreshed during the message loop...   
                                        mY = msg.GetLong(BFM_DRAG_SCREENY);   
                                        Screen2Local(&mX;,&mY;);   
                                          if(mX < Xs-10)// || mXt > (Xs+10) || mYt > (Yl+10) || mYt < (Yl-10))   
                                          {   
                                               GePrint("Breaking..");   
                                               break;   
                                          }   
                                          GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSELEFT, bc);   
                                          if(bc.GetLong(BFM_INPUT_VALUE) == 1)   
                                          {   
                                               GePrint("Mouse down..");   
                                               break;   
                                          }   
                                  }   
                           break;   
                           }
            

            Are we not able to do this? Or is there a bug in there somewhere? I've had to strip my code above of things related to my userarea so I hope it's as general as can be. Is someone able to confirm this one way or another?

            All I'm trying to do is change the mouse while it's coordinates are over a certain part of the userarea. Everything works except for any loop I put in. The coordinates are not refreshed and hence my mouse changes to the appropriate arrow, but it won't change back without me having to make a user interaction of some sort.

            Printing the co-ords in the loop prints the same numbers all the time, despite having some code that I thought would update them.

            WP.

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

              On 14/04/2013 at 04:45, xxxxxxxx wrote:

              You'll get a BFM_GETCURSORINFO for each mouse movement.  I don't think there is any way to 'poll' the mouse movement without a button down.

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