]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
Fix accelerstors with down and left
[wxWidgets.git] / src / mac / carbon / window.cpp
index c687bedb060d038983b0930e307aef36a7afdbb9..47a280bc4d4d83e3b9343e128ada44dd5a42d4f0 100644 (file)
@@ -167,9 +167,11 @@ static const EventTypeSpec eventList[] =
     { kEventClassTextInput, kEventTextInputUpdateActiveInputArea } ,
 
     { kEventClassControl , kEventControlDraw } ,
+#if TARGET_API_MAC_OSX
     { kEventClassControl , kEventControlVisibilityChanged } ,
     { kEventClassControl , kEventControlEnabledStateChanged } ,
     { kEventClassControl , kEventControlHiliteChanged } ,
+#endif
     { kEventClassControl , kEventControlSetFocusPart } ,
 
     { kEventClassService , kEventServiceGetTypes },
@@ -513,7 +515,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
         uniChars = new wchar_t[ numChars ] ;
         GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
 #if SIZEOF_WCHAR_T == 2
-        uniChars = charBuf ;
+        uniChars = (wchar_t*) charBuf ;
         memcpy( uniChars , charBuf , dataSize ) ;
 #else
         // the resulting string will never have more chars than the utf16 version, so this is safe
@@ -585,7 +587,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
     delete [] uniChars ;
     if ( charBuf != buf )
         delete [] charBuf ;
-    
+
     return result ;
 }
 
@@ -1256,14 +1258,24 @@ void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
 
 bool wxWindowMac::MacCanFocus() const
 {
-    // there is currently no way to determine whether the window is running in full keyboard
-    // access mode, therefore we cannot rely on these features, yet the only other way would be
-    // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
-    // in event handlers...
-    UInt32 features = 0 ;
-    m_peer->GetFeatures( &features ) ;
+    // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
+    // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
+    // but the value range is nowhere documented
+    Boolean keyExistsAndHasValidFormat ;
+    CFIndex fullKeyboardAccess = CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
+        kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat );
 
-    return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ;
+    if ( keyExistsAndHasValidFormat && fullKeyboardAccess > 0 )
+    {
+        return true ;
+    }
+    else
+    {
+        UInt32 features = 0 ;
+        m_peer->GetFeatures( &features ) ;
+
+        return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ;
+    }
 }
 
 void wxWindowMac::SetFocus()
@@ -1326,7 +1338,7 @@ void wxWindowMac::DoCaptureMouse()
     wxApp::s_captureWindow = this ;
 }
 
-wxWindow* wxWindowBase::GetCapture()
+wxWindow * wxWindowBase::GetCapture()
 {
     return wxApp::s_captureWindow ;
 }
@@ -1352,7 +1364,7 @@ void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
 
 #endif
 
-// Old style file-manager drag&drop
+// Old-style File Manager Drag & Drop
 void wxWindowMac::DragAcceptFiles(bool accept)
 {
     // TODO:
@@ -1375,10 +1387,7 @@ bool wxWindowMac::MacGetBoundsForControl(
     int& x, int& y,
     int& w, int& h , bool adjustOrigin ) const
 {
-    bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
-
     // the desired size, minus the border pixels gives the correct size of the control
-
     x = (int)pos.x;
     y = (int)pos.y;
 
@@ -1386,6 +1395,7 @@ bool wxWindowMac::MacGetBoundsForControl(
     w = wxMax(size.x, 0) ; // WidthDefault( size.x );
     h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ;
 
+    bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
     if ( !isCompositing )
         GetParent()->MacWindowToRootWindow( &x , &y ) ;