Show
Ignore:
Timestamp:
05/28/09 16:09:16 (5 years ago)
Author:
robert
Message:

From Stephan Huber, "attached you'll find a small fix for GrphicsWindowCocoa?. There was a bug
with certain key-strokes, which led to a crash."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowCocoa.mm

    r10242 r10285  
    670670     
    671671    NSString* chars = [theEvent charactersIgnoringModifiers];  
    672     unsigned int keyCode = remapCocoaKey([chars characterAtIndex:0], ([theEvent modifierFlags] & NSFunctionKeyMask) ); 
    673     // std::cout << "key dn: " <<[chars characterAtIndex:0] << "=" << keyCode << std::endl;    
    674     _win->getEventQueue()->keyPress( remapCocoaKey(keyCode), [theEvent timestamp]); 
     672    if ((chars) && ([chars length] > 0)) { 
     673        unsigned int keyCode = remapCocoaKey([chars characterAtIndex:0], ([theEvent modifierFlags] & NSFunctionKeyMask) ); 
     674        // std::cout << "key dn: " <<[chars characterAtIndex:0] << "=" << keyCode << std::endl;    
     675        _win->getEventQueue()->keyPress( remapCocoaKey(keyCode), [theEvent timestamp]); 
     676    } 
    675677} 
    676678 
     
    681683     
    682684    NSString* chars = [theEvent charactersIgnoringModifiers];  
    683     unsigned int keyCode = remapCocoaKey([chars characterAtIndex:0], ([theEvent modifierFlags] & NSFunctionKeyMask)); 
    684     // std::cout << "key up: " <<[chars characterAtIndex:0] << "=" << keyCode << std::endl;    
    685     _win->getEventQueue()->keyRelease( remapCocoaKey(keyCode), [theEvent timestamp]); 
     685    if ((chars) && ([chars length] > 0)) { 
     686        unsigned int keyCode = remapCocoaKey([chars characterAtIndex:0], ([theEvent modifierFlags] & NSFunctionKeyMask)); 
     687        // std::cout << "key up: " <<[chars characterAtIndex:0] << "=" << keyCode << std::endl;    
     688        _win->getEventQueue()->keyRelease( remapCocoaKey(keyCode), [theEvent timestamp]); 
     689    } 
    686690} 
    687691