<div>Hello. I am making a userinterface, and i need to capture keyboard events.</div>
<div>I have found this codesnippet written in python, but i cannot really translate it into C++.</div>
<div>It is especially the lines </div>
<div> </div>
<div> def Keypress(obj, event):<br> global mpr, mip, surface</div>
<div> </div>
<div>that i dont know how to translate..If someone could just help me with those 2 lines i would be grateful.</div>
<div>Thank you all</div>
<div> </div>
<div> </div>
<div>Snippet :</div>
<div>
<p> def Keypress(obj, event):<br> global mpr, mip, surface<br> key = obj.GetKeySym()<br> if key == "1":<br> if mpr:<br> planeX.EnabledOff()<br> planeY.EnabledOff()<br> planeZ.EnabledOff()<br> mpr = 0
<br> else:<br> planeX.EnabledOn()<br> planeY.EnabledOn()<br> planeZ.EnabledOn()<br> mpr = 1<br> <br> elif key == "2":<br> if mip:<br> volume.VisibilityOff()<br> mip = 0<br> renWin.Render
()<br> else:<br> volume.VisibilityOn()<br> mip = 1<br> renWin.Render()</p>
<p> elif key == "3":<br> if surface:<br> surfaceActor.VisibilityOff()<br> surface = 0<br> renWin.Render()<br> else:<br> surfaceActor.VisibilityOn()<br> surface = 1<br> renWin.Render()</p>
<p> def ButtonEvent(obj, event):<br> planeX.EnabledOff()<br> planeY.EnabledOff()<br> planeZ.EnabledOff()<br> <br> iren.AddObserver("KeyPressEvent", Keypress)<font size="1"></font></p></div>