Hi, I fordward this thread to the VM mailing list since it looks more appropiated. <br>David, here &quot;tn&quot; is proposing a fix. I am not qualified to take a look.<br>Hope it helps<br><br>Mariano<br><br><div class="gmail_quote">
---------- Forwarded message ----------<br>From: <b class="gmail_sendername"></b> <span dir="ltr">&lt;<a href="mailto:pharo@googlecode.com">pharo@googlecode.com</a>&gt;</span><br>Date: Sat, Mar 5, 2011 at 9:23 PM<br>Subject: Re: [Pharo-project] Issue 1064 in pharo: There are still problem with keyboard shortcuts in Windows<br>
To: <a href="mailto:pharo-project@lists.gforge.inria.fr">pharo-project@lists.gforge.inria.fr</a><br><br><br><br>
Comment #14 on issue 1064 by <a href="mailto:happy.lo...@gmail.com" target="_blank">happy.lo...@gmail.com</a>: There are still problem with keyboard shortcuts in Windows<div class="im"><br>
<a href="http://code.google.com/p/pharo/issues/detail?id=1064" target="_blank">http://code.google.com/p/pharo/issues/detail?id=1064</a><br>
<br></div><div><div></div><div class="h5">
Hi, I&#39;m tn.<br>
<br>
&#39;ctrl + m&#39; problem is Cog VM bug.<br>
<br>
Normally, when character key is pushed, keyboard events occur as follows on Squeak.<br>
<br>
1. key press (down)<br>
2. character (character code notification)<br>
3. key release (up)<br>
<br>
They are produced by a primitive method in IutEventFetcher &gt;&gt; primGetNextEvent.<br>
But when ctrl + m is pushed, a character event doesn&#39;t occur.<br>
Because &#39;ctrl + m&#39; value is 13. The value is same as ENTER key.<br>
Cog VM ignores WM_CHAR message(character event) when ENTER key is pushed.<br>
<br>
The one of solution for this problem is to add CTRL key state to the if-condition.<br>
<br>
-- sqWin32Window.c --<br>
<br>
int recordKeyboardEvent(MSG *msg) {<br>
  ...<br>
<br>
  switch(msg-&gt;message) {<br>
    ...<br>
<br>
    case WM_CHAR:<br>
    case WM_SYSCHAR:<br>
      /* Note: VK_RETURN is recorded as virtual key ONLY */<br>
      if(keyCode == 13  &amp;&amp; !ctrl) return 1;            // add &quot;&amp;&amp; !ctrl&quot;<br>
      pressCode = EventKeyChar;<br>
      break;<br>
    ...<br>
  }<br>
  ...<br>
<br>
Note: ENTER keyCode is 13. But when ctrl + ENTER is pushed, the keyCode is 10.<br>
So if the condition is revised, ctrl + m problem is corrected.<br>
but other behavior is not changed.<br>
<br>
<br>
If you want to prevent to generate character event for CTRL + ENTER,<br>
you can add following code. By this way, we can produce<br>
not only ctrl+m (0x0D)&#39;s character event but also ctrl+j (0x0A)&#39;s one.<br>
<br>
-- sqWin32Window.c --<br>
<br>
// add this function<br>
static int isNotKeyDownCtrlReturn(MSG* msgp){<br>
    if(msgp-&gt;message == WM_KEYDOWN &amp;&amp; msgp-&gt;wParam == VK_RETURN){<br>
        if(GetKeyState(VK_CONTROL) &amp; 0x8000) {<br>
            return FALSE;<br>
        }<br>
    }<br>
    return TRUE;<br>
}<br>
<br>
...<br>
<br>
int ioProcessEvents(void)<br>
{ static MSG msg;<br>
  ...<br>
      if(isNotKeyDownCtrlReturn(&amp;msg)){  // add<br>
        TranslateMessage(&amp;msg);<br>
      }                                  // add<br>
      DispatchMessage(&amp;msg);<br>
  ...<br>
}<br>
<br>
...<br>
<br>
int recordKeyboardEvent(MSG *msg) {<br>
  ...<br>
<br>
  if(pressCode == EventKeyDown &amp;&amp; virtCode != 0 &amp;&amp; isNotKeyDownCtrlReturn(lastMessage) ) {<br>
                                                   // add &quot; &amp;&amp; isNotKeyDownCtrlReturn(lastMessage) &quot;<br>
    /* generate extra character event */<br>
    ...<br>
  }<br>
  return 1;<br>
}<br>
<br></div></div><div class="im">
An attached file is source, which has been corrected by above way.<br>
<br>
<br></div><div class="im">
Note: Below is a comment in the source code.<br>
<br>
  /* note: several keys are not reported as character events;<br>
     most noticably the mapped virtual keys. For those we<br>
     generate extra character events here */<br>
<br>
Those keys(e.g. arrow) should not be ascii code.<br>
ENTER key is not. but an extra character events is created for ENTER.<br>
I don&#39;t think this behavior is correct.<br>
As for ENTER key, an extra character event must not be generated,<br></div>
and WM_CHAR message should be processed.<br>
Please see MSDN about TranslateMessage.<div><div></div><div class="h5"><br>
<br>
see also Comment 11.<br>
<br>
Thanks,<br>
<br>
Attachments:<br>
        sqWin32Window.c  99 KB<br>
<br>
<br>
</div></div></div><br>