<p>I have been trying to implement the following functionality in my code:
<br>There are 2 flags editMode and deleteMode, both set to zero.
<br>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.:</p>

<pre><code>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)
</code></pre>

<p>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.
<br> Is there anything specific to the mouse listener which I am missing?
<br> Any new way to set controls for the above functions is welcome..
<br> Thank you.. 
<br> EDIT  1:
<br> I modified the logic a bit. So I have:</p>

<pre><code>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) }
}
</code></pre>

<p>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.</p>

CC BY-SA 3.0
2015-11-17T16:25:10.333Z
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
CC BY-SA 3.0
2015-11-17T16:27:28.313Z
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
CC BY-SA 3.0
2015-11-17T16:30:30.950Z
is that pseudo code or the actual code in your app (if so what language)?
ratchet freak
CC BY-SA 3.0
2015-11-17T16:51:53.837Z
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
CC BY-SA 3.0
2015-11-17T17:44:41.283Z
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 is on Codidact now
CC BY-SA 3.0
2015-11-17T17:47:03.237Z
Relevant discussion on Meta about [whether we should require a minimal working example](http://meta.computergraphics.stackexchange.com/questions/126/should-we-require-minimal-working-examples-mwes). This needs more attention to make clear the community consensus.
trichoplax is on Codidact now
CC BY-SA 3.0
2015-11-21T23:31:38.017Z
This question is not exactly about OpenGL and Graphics but about GLUT and Input. Might be better suited for http://gamedev.stackexchange.com/
Wumpf
<opengl>
How does function for mouse in glutMouseFunc(mouse) work in openGL?
shane
# How does function for mouse in glutMouseFunc(mouse) work in openGL?

(Asked by: username_0 on 2015-11-17)

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.

**Tags:** opengl

> **Comments:**
> **username_1**: is it possible for bode the modes to be set to 1? and if it shouldn't be are you guarding against it?  
> **username_0**: 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'.  
> **username_1**: is that pseudo code or the actual code in your app (if so what language)?  
> **username_0**: 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.  
> **username_2**: 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.  
> **username_2**: Relevant discussion on Meta about [whether we should require a minimal working example](http://meta.computergraphics.stackexchange.com/questions/126/should-we-require-minimal-working-examples-mwes). This needs more attention to make clear the community consensus.  
> **username_3**: This question is not exactly about OpenGL and Graphics but about GLUT and Input. Might be better suited for http://gamedev.stackexchange.com/  

---

## 0 answers

