Hi Brad,
I hate arguing :) ... For me it works. I put a break point on the Sleep and
I get there
BOOL CDialogDlg::PreTranslateMessage( MSG *pMsg )
{
if (pMsg->message == WM_CHAR )
{
// will I get here
Sleep(10);
}
return CDialog::PreTranslateMessage(pMsg);
}
-Nick
On Mon, Sep 20, 2010 at 9:28 PM, Brad Huber <[email protected]> wrote:
> Nick,
>
>
>
> According to my understanding and experience,
> CDialog::PreTranslateMessage(MSG *msg) does not receive WM_CHAR messages so
> I cannot do anything about that. In the MFC documentation there is a
> CWnd::GetDlgCode method which tells the framework which key messages (like
> WM_CHAR) your class would like to receive but again this does not work for
> CDialog classes. GetDlgCode does not get called and PreTranslateMessage
> does not ever get WM_CHAR. Therefore I cannot use any WM_CHAR based
> mechanism with my existing CDialog based app. I can use a work around (ie
> don’t rely on any WM_KEYDOWN) and use WM_KEYUP instead. I could also
> investigate inserting a control on top of the dialog which would allow
> receipt of WM_CHAR messages. Anyway there is apparently nothing I can do to
> force WM_CHAR to work with CDialog.
>
>
>
> Thanks
>
> -Brad
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Trajce (Nick)
> Nikolov
> *Sent:* Monday, September 20, 2010 11:06 AM
> *To:* OpenSceneGraph Users
>
> *Subject:* Re: [osg-users] Keypress broken since rev 11749
>
>
>
> Hi Brad,
>
>
>
> Dialogs in MFC do not capture/receive the WM_CHAR message and that is why I
> cannot properly pass it on to the OSG window
>
>
>
> you could override CDialog::PreTranslateMessage( MSG* msg ) and do it the
> same way is CView from the osgviewerMFC example
>
>
> -Nick
>
> On Mon, Sep 20, 2010 at 5:29 PM, Brad Huber <[email protected]>
> wrote:
>
> Gentlemen,
>
>
>
> I apologize for being inactive on the thread these last few days. I was on
> vacation at the Reno Air Races J.
>
>
>
> Trajce- to address your point about how to make MFC “work properly”. The
> example code IS NOT a dialog based MFC app. My app IS a dialog based MFC
> app. Dialogs in MFC do not capture/receive the WM_CHAR message and that is
> why I cannot properly pass it on to the OSG window. Of course there are
> other work arounds that address my particular problem (I believe I’ve
> already fixed it), but I’m trying to bring up the point that this may be a
> fundamental issue in the key handling.
>
>
>
> Robert- One issue with including both the translated and untranslated keys
> in the event is that there is not a one to one mapping. In windows
> sometimes 3 key presses will translate to one WM_CHAR (translated key)
> message and they don’t even need to be pressed at the same time (in the case
> of dead keys). Whereas I believe there is a one-to-one between WM_KEYDOWN
> and key presses…
>
>
>
> Thanks
>
> -Brad
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Trajce (Nick)
> Nikolov
> *Sent:* Friday, September 17, 2010 10:57 AM
>
>
> *To:* [email protected]
> *Subject:* Re: [osg-users] Keypress broken since rev 11749
>
>
>
> Hi Robert,
>
>
>
> I find some time to dig into this. And here are my observations ( I am
> working with Vivien's submission, with osgviewerMFC )
>
>
>
> I put break points in GraphicsWindowWin32.cpp:
>
> Line: 2476
>
> case WM_KEYDOWN :
>
> case WM_SYSKEYDOWN :
>
> ////////////////////
>
>
>
> {
>
> int keySymbol = 0;
>
>
>
> Line: 2451
>
> /////////////////
>
> case WM_CHAR :
>
> /////////////////
>
> {
>
> // if event was not handled by WM_KEYDOWN then we take care
> of it here
>
> // this method gives directly the utf16 char back so just
> need to add it as it is
>
> if(!_keypresshandled)
>
> {
>
> // first check if key is already registered on the map
>
>
>
>
>
> case WM_KEYDOWN/WM_SYSKEYDOWN : get its chance to handle every single key
> you press, even a dead key. So, for my czech character 'č', I have to press:
> SHIFT, '+', and 'c', in this order, and for each of these three I get
> WM_KEYDOWN. The only difference is that when I complete this sequence, on
> top of all WM_KEYDOWNs, it gets to case WM_CHAR: with my 'č'. This is how
> the system is managing these events. To reflect this behavior into OSG, only
> one single line needs to be added, I think, and that will fix Brad's issue
> as well:
>
>
>
> else
>
> {
>
> // was no special key, let WM_CHAR handle it
>
> _keypresshandled = false;
>
> _lastkeysymbol = keySymbol;
>
> /* the new line
> */ getEventQueue()->keyPress(keySymbol, eventTime);
>
> }
>
>
>
> This was the key that was waste (being 'eaten' :) ..).
>
>
>
> So to me it sounds that, with Vivien's submission, only the dead key +
> 'something' was not firing an event in osg - for the rest it should work as
> before, not as Brad states above that the key events stopped work. I am
> very curious what he was actually doing.
>
>
>
> Cheers,
>
> -Nick
>
> On Fri, Sep 17, 2010 at 8:04 PM, Vivien Delage <[email protected]> wrote:
>
> Hi guys,
>
> I understand you Robert. I have no problem with reverting the code for now
> if this causes issues for other people. I will go and experiment a bit more
> on how to fix the dead key problem. Maybe I can find a solution which is not
> using the WM_CHAR message. I will let you know how it goes on my side.
>
>
> Cheers,
>
> Vivien
>
> ------------------
> Read this topic online here:
>
> http://forum.openscenegraph.org/viewtopic.php?p=31778#31778
>
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org