<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>&nbsp;</div>
<div>&nbsp;def Keypress(obj, event):<br>&nbsp;global mpr, mip, surface</div>
<div>&nbsp;</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>&nbsp;</div>
<div>&nbsp;</div>
<div>Snippet :</div>
<div>
<p>&nbsp;def Keypress(obj, event):<br>&nbsp;&nbsp;global mpr, mip, surface<br>&nbsp;&nbsp;key = obj.GetKeySym()<br>&nbsp;&nbsp;if key == &quot;1&quot;:<br>&nbsp;&nbsp;&nbsp;if mpr:<br>&nbsp;&nbsp;&nbsp;&nbsp;planeX.EnabledOff()<br>&nbsp;&nbsp;&nbsp;&nbsp;planeY.EnabledOff()<br>&nbsp;&nbsp;&nbsp;&nbsp;planeZ.EnabledOff()<br>&nbsp;&nbsp;&nbsp;&nbsp;mpr = 0
<br>&nbsp;&nbsp;&nbsp;else:<br>&nbsp;&nbsp;&nbsp;&nbsp;planeX.EnabledOn()<br>&nbsp;&nbsp;&nbsp;&nbsp;planeY.EnabledOn()<br>&nbsp;&nbsp;&nbsp;&nbsp;planeZ.EnabledOn()<br>&nbsp;&nbsp;&nbsp;&nbsp;mpr = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;elif key == &quot;2&quot;:<br>&nbsp;&nbsp;&nbsp;if mip:<br>&nbsp;&nbsp;&nbsp;&nbsp;volume.VisibilityOff()<br>&nbsp;&nbsp;&nbsp;&nbsp;mip = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;renWin.Render
()<br>&nbsp;&nbsp;&nbsp;else:<br>&nbsp;&nbsp;&nbsp;&nbsp;volume.VisibilityOn()<br>&nbsp;&nbsp;&nbsp;&nbsp;mip = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;renWin.Render()</p>
<p>&nbsp;&nbsp;elif key == &quot;3&quot;:<br>&nbsp;&nbsp;&nbsp;if surface:<br>&nbsp;&nbsp;&nbsp;&nbsp;surfaceActor.VisibilityOff()<br>&nbsp;&nbsp;&nbsp;&nbsp;surface = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;renWin.Render()<br>&nbsp;&nbsp;&nbsp;else:<br>&nbsp;&nbsp;&nbsp;&nbsp;surfaceActor.VisibilityOn()<br>&nbsp;&nbsp;&nbsp;&nbsp;surface = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;renWin.Render()</p>

<p>&nbsp;def ButtonEvent(obj, event):<br>&nbsp;&nbsp;planeX.EnabledOff()<br>&nbsp;&nbsp;planeY.EnabledOff()<br>&nbsp;&nbsp;planeZ.EnabledOff()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;iren.AddObserver(&quot;KeyPressEvent&quot;, Keypress)<font size="1"></font></p></div>