GetPoint MouseDown Event

Hello,

I am trying to perform a custom action in the MouseDown event of a GetPoint derived class. The instances of the GetPoint are created in a loop so that I can get the MouseDown event once per each Get(true) operation like the documentation says. But for some reason, the event is only triggered on every other Get operation, instead of all the clicks. Does anyone know why this happens ?

using Rhino;
using Rhino.Commands;
using Rhino.Input;
using Rhino.Input.Custom;

namespace RhGodzilla.Commands
{
    public class GetPointTest : Command
    {
        public GetPointTest()
        {
            Instance = this;
        }

        public static GetPointTest Instance { get; private set; }

        public override string EnglishName => "GetPointTest";

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {

            while (true)
            {
                var gp = new TestGP();
                var result = gp.Get(true);
                if (result == GetResult.Point)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            return Result.Success;
        }
    }

    class TestGP : GetPoint
    {
        public TestGP()
        {
            AcceptNothing(true);
        }

        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            base.OnMouseDown(e);
        }
    }
}

Hi @bovasbenjacob,

This seems to work:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var count = 0;
  var gp = new GetPoint();
  while (count < 100)
  {
    var result = gp.Get(true);
    if (result == Rhino.Input.GetResult.Point)
    {
      var dot = new TextDot(count.ToString(), gp.Point());
      doc.Objects.Add(dot);
      count++;
      continue;
    }
    break;
  }
  return Result.Success;
}

Make sure you are not double-clicking…

– Dale

Hi @dale,
Thank you for the reply. I should have been more clear in my question. The problem I am facing is that if I put a BreakPoint inside the OnMouseDown method of the GetPoint class(TestGP in my sample code), it is not hit every time I click. So I run the command, first GetPoint is on, I click and the BreakPoint is hit. After MouseUp, a new GetPoint is created and when I click the BreakPoint should be hit again, but it’s not happening.

Yes, the joys of debugging Windows events. Mouse clicks are pretty low on the Windows message priority. I’m certain the message queue has been flushed by the time you code resumes.

– Dale

Did you mean that the event itself is not triggered every time, or that event runs each click and it’s the clearing of message queue that is causing the Breakpoint to not be hit? I also tried adding a Windows message box inside the event without the Breakpoint, but problem persists.

Try adding some print statements…

– Dale

Okay, print statements did seem to be working, but I was not sure what to make of it, or if it was even working because of the missing Breakpoint. Thank you for clearing this up!