# How does function for mouse in glutMouseFunc(mouse) work in openGL? [closed]

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.

## closed as off-topic by glampert, Nathan Reed, joojaa, Wumpf, RichieSamsDec 2 '15 at 18:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about computer graphics, within the scope defined in the help center." – glampert, Nathan Reed, joojaa, Wumpf
If this question can be reworded to fit the rules in the help center, please edit the question.

• is it possible for bode the modes to be set to 1? and if it shouldn't be are you guarding against it? – ratchet freak Nov 17 '15 at 16:25
• for now I am assuming that the user is either in editMode or deleteMode. he doesn't press 'c' and 'd' together. if 'c' is pressed, it is made sure he exits from editMode before pressing ' d'. – shane Nov 17 '15 at 16:27
• is that pseudo code or the actual code in your app (if so what language)? – ratchet freak Nov 17 '15 at 16:30
• its c++. and this is the pseudo code giving the general idea of what I want to achieve. The actual code has some other flags for calling drawBeizer fn etc. – shane Nov 17 '15 at 16:51
• It may help to try to remove everything from your code that you can, without removing the problem. This may highlight the cause for you, but even if it doesn't you can then edit the minimal code into your question, which will increase the chance of someone being able to spot the underlying cause. – trichoplax Nov 17 '15 at 17:44