Get keydown in CRhinoGetPoint() (c++)

Hi:
how can I get the keydown anh mouse button in CRhinoGetPoint()?
for example, I press shif + left mouse button, how can I get them?

Hi @pythonuser,

A CRhinoGetPoint-derived class that looks somewhat like the following should work.

class CMyGetPoint : public CRhinoGetPoint
{
public:
  // Constructor
  CMyGetPoint()
    : m_bCtrl(false)
    , m_bShift(false)
  {
  }

  // OnMouseDown override
  void OnMouseDown(
    CRhinoViewport& vp,
    UINT flags,
    const ON_3dPoint&
    point,
    const CPoint* pt
  )
  {
    m_bCtrl = (::GetKeyState(VK_CONTROL) < 0);
    m_bShift = (::GetKeyState(VK_SHIFT) < 0);
    CRhinoGetPoint::OnMouseDown(vp, flags, point, pt);
  }

  // Returns the state of the Ctrl key during point picking
  bool IsControlKeyDown() const
  {
    return m_bCtrl;
  }

  // Returns the state of the Shift key during point picking
  bool IsShiftKeyDown() const
  {
    return m_bShift;
  }

private:
  bool m_bCtrl;
  bool m_bShift;
};

– Dale

Hi @dale:
Thinks, it run good.

if I want to get all the key of “shif + left mouse button”, cant I do like this?

class CMyGetPoint : public CRhinoGetPoint
{
public:
// Constructor
CMyGetPoint()
: m_bCtrl(false)
, m_bShift(false), m_ml(false)
{
}

// OnMouseDown override
void OnMouseDown(
CRhinoViewport& vp,
UINT flags,
const ON_3dPoint&
point,
const CPoint* pt
)
{
m_bCtrl = (::GetKeyState(VK_CONTROL) < 0);
m_bShift = (::GetKeyState(VK_SHIFT) < 0);
m_ml = (::GetKeyState(WM_LBUTTONDOWN) < 0);
if(m_bShift ==false && m_ml==true)
{
//do something
}
CRhinoGetPoint::OnMouseDown(vp, flags, point, pt);
}

// Returns the state of the Ctrl key during point picking
bool IsControlKeyDown() const
{
return m_bCtrl;
}

// Returns the state of the Shift key during point picking
bool IsShiftKeyDown() const
{
return m_bShift;
}

bool IsMouseLeftDown() const
{
return m_ml;
}

private:
bool m_bCtrl;
bool m_bShift;
bool m_ml;
};

Hi @pythonuser,

CRhinoGetPoint::OnMouseDown is only called when the left mouse button is down.

And, you do this, rather than call GetKeyState:

  void OnMouseDown(
    CRhinoViewport& vp,
    UINT flags,
    const ON_3dPoint& point,
    const CPoint* view_wnd_point
  )
  {
    m_bCtrl = (0 != (flags & MK_CONTROL));
    m_bShift = (0 != (flags & MK_SHIFT));
    CRhinoGetPoint::OnMouseDown(vp, flags, point, view_wnd_point);
  }

– Dale

Hi @dale:
Think you.