I have been trying to implement the following functionality in my code:
There are 2 flags editMode and deleteMode, both set to zero.
with the help of keys function in glutKeyBoardFunc(keys) the user can press keys ( 'c' and 'd' respectively) to set editMode and deleteMode to 1.The following is the algo for my mouse fucntion.:
when ( editMode == 0)
left click plots the point
right click plots beizer curve
when ( editMode == 1)
left click to displace the point to new postion and draw new beizer curve
right click to exit editMode(i.e set editMode to 0)
when (deleteMode = 1)
left click to click any point to delete it and draw new beizer curve
right click to exit delete mode(i.e set deleteMode to 0)
The problem is when I am in editMode == 1, on first instance of left click my delete function is called to delete a point in beizer curve.
Is there anything specific to the mouse listener which I am missing?
Any new way to set controls for the above functions is welcome..
Thank you..
EDIT 1:
I modified the logic a bit. So I have:
when( deleteMode == 0)
{ when (editMode == 0)
left click to plot points
right click to plot beizer
else when (editFlag == 1)
left click to displace points and draw new beizer curve
right click to exit editMode(i.e set editMode to 0)
}
else
{
when ( left_mouse_button == TRUE)
{ if(editMode == 0 ) delete chosen point and draw new beizer curve}
when ( right_mouse_button == TRUE)
{ exit deleteMode e(i.e set deleteMode to 0) }
}
This works fairly for most of the time.And is serving my purpose for now.I have the assumption that the user goes to one mode and exits from that mode before going into other mode.