<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-06-16 14:44 GMT+02:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Jun 16, 2016 at 6:32 AM, Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>2016-06-16 14:12 GMT+02:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Elvis,<div><br></div><div>The commit logs might hold the answers to some of your questions.</div><div><br></div><div>Here's the history line for when QVTKRenderWindowInteractor.py was created:</div><div><a href="https://gitlab.kitware.com/vtk/vtk/commits/720b580c/Wrapping/Python/vtk/qt/QVTKRenderWindowInteractor.py" target="_blank">https://gitlab.kitware.com/vtk/vtk/commits/720b580c/Wrapping/Python/vtk/qt/QVTKRenderWindowInteractor.py</a><br></div><div><br></div><div>The history continues here:</div><div><a href="https://gitlab.kitware.com/vtk/vtk/commits/3f70e5ff/Wrapping/Python/vtk/qt4/QVTKRenderWindowInteractor.py" target="_blank">https://gitlab.kitware.com/vtk/vtk/commits/3f70e5ff/Wrapping/Python/vtk/qt4/QVTKRenderWindowInteractor.py</a><br></div><div><br></div><div>And finally comes to the present:</div><div><a href="https://gitlab.kitware.com/vtk/vtk/commits/master/Wrapping/Python/vtk/qt/QVTKRenderWindowInteractor.py" target="_blank">https://gitlab.kitware.com/vtk/vtk/commits/master/Wrapping/Python/vtk/qt/QVTKRenderWindowInteractor.py</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">Also, here is some pre-history:</div><div class="gmail_quote"><a href="https://gitlab.kitware.com/vtk/vtk/commits/bae05540/Wrapping/Python/QVTKRenderWidget.py" target="_blank">https://gitlab.kitware.com/vtk/vtk/commits/bae05540/Wrapping/Python/QVTKRenderWidget.py</a></div><div class="gmail_quote"><a href="https://gitlab.kitware.com/vtk/vtk/tree/5b48ce33/Wrapping/Python" target="_blank">https://gitlab.kitware.com/vtk/vtk/tree/5b48ce33/Wrapping/Python</a><span><font color="#888888"><br></font></span></div><span><font color="#888888"><div class="gmail_quote"><br></div></font></span></div></div></blockquote><div><br></div></span><div>Thanks for the pointers, but it seems the code was like that when the Qt 4 variant was initially contributed by Phil Thomson:<br><br>    <a href="https://gitlab.kitware.com/vtk/vtk/commit/720b580c32b1ab002572fa59d796e409b5b0c346" target="_blank">https://gitlab.kitware.com/vtk/vtk/commit/720b580c32b1ab002572fa59d796e409b5b0c346</a></div></div></div></div></blockquote><div><br></div></span><div>Wrong.  You might need to practice your detective skills some more :)</div><div><br></div><div><div><a href="https://gitlab.kitware.com/vtk/vtk/commit/0ab4f15f" target="_blank">https://gitlab.kitware.com/vtk/vtk/commit/0ab4f15f</a></div></div><span class=""><div><br></div></span></div></div></div></blockquote><div><br></div><div>Bah, indeed :) Sorry for my sloppiness.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>But even if we forget about history/origin, doesn't it seem strange to use <span><span>str</span><span>(</span><span>ev</span><span>.</span><span>text</span><span>()) in the keyPressEvent?</span></span></div></div></div></div></blockquote><div><br></div></span><div>Yes, it seems strange, but there might be a reason.  You'll have to experiment with Qt to see what str(ev.text()) and chr(ev.key()) return under various situations.</div></div></div></div></blockquote><div><br></div><div>Okay, that was easy:<br><br>str(ev.text()): d<br>chr(ev.key()): D<br>str(ev.text()): f<br>chr(ev.key()): F<br>str(ev.text()): g<br>chr(ev.key()): G<br>str(ev.text()): h<br>chr(ev.key()): H<br>str(ev.text()): j<br>chr(ev.key()): J<br>...<br><br></div><div>So that fix was indeed correct, and from the Qt docs for key():<br><br>"Note that this function does not distinguish between capital and non-capital letters, use the <a href="http://doc.qt.io/qt-5/qkeyevent.html#text">text</a>() function (returning the Unicode text the key generated) for this purpose."<br><br></div><div>So I guess keyReleaseEvent should be changed to also use str(ev.text()). But thinking more about how Qt's key() is used in QVTKRenderWindowInteractor, for example:<br><br>if ev.key() < 256:<br>    ...<br><br></div><div>Is it not wrong to make assumptions about the .key() as a number like this? I don't think Qt gives any guarantee that the Qt::Key enum values correspond to ASCII values? (even if they currently do). Shouldn't the code first call .text() and then check that it's a single byte string, instead of making assumptions about the layout of the Qt::Key enum?<br><br></div><div>Elvis<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><font color="#888888"><div><br></div><div> - David</div><div> </div></font></span></div><br></div></div>
</blockquote></div><br></div></div>