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..
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)
       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.

  • $\begingroup$ is it possible for bode the modes to be set to 1? and if it shouldn't be are you guarding against it? $\endgroup$ – ratchet freak Nov 17 '15 at 16:25
  • $\begingroup$ 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'. $\endgroup$ – shane Nov 17 '15 at 16:27
  • $\begingroup$ is that pseudo code or the actual code in your app (if so what language)? $\endgroup$ – ratchet freak Nov 17 '15 at 16:30
  • $\begingroup$ 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. $\endgroup$ – shane Nov 17 '15 at 16:51
  • 1
    $\begingroup$ 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. $\endgroup$ – trichoplax Nov 17 '15 at 17:44

Browse other questions tagged or ask your own question.