break ;
#endif
case kEventClassAppleEvent :
- {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if ( AEProcessEvent != NULL )
- {
- result = AEProcessEvent(event);
- }
-#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
- {
- EventRecord rec ;
-
- wxMacConvertEventToRecord( event , &rec ) ;
- result = AEProcessAppleEvent( &rec ) ;
- }
-#endif
- }
+ result = AEProcessEvent(event);
break ;
default :
{
// remove this argument
--argc;
- memmove(argv + 1, argv + 2, argc * sizeof(char *));
+ memmove(argv + 1, argv + 2, argc * sizeof(wxChar*));
+ }
+ }
+
+ /*
+ Cocoa supports -Key value options which set the user defaults key "Key"
+ to the value "value" Some of them are very handy for debugging like
+ -NSShowAllViews YES. Cocoa picks these up from the real argv so
+ our removal of them from the wx copy of it does not affect Cocoa's
+ ability to see them.
+
+ We basically just assume that any "-NS" option and its following
+ argument needs to be removed from argv. We hope that user code does
+ not expect to see -NS options and indeed it's probably a safe bet
+ since most user code accepting options is probably using the
+ double-dash GNU-style syntax.
+ */
+ for(int i=1; i < argc; ++i)
+ {
+ static const wxChar *ARG_NS = wxT("-NS");
+ if( wxStrncmp(argv[i], ARG_NS, wxStrlen(ARG_NS)) == 0 )
+ {
+ // Only eat this option if it has an argument
+ if( (i + 1) < argc )
+ {
+ memmove(argv + i, argv + i + 2, (argc-i-1)*sizeof(wxChar*));
+ argc -= 2;
+ // drop back one position so the next run through the loop
+ // reprocesses the argument at our current index.
+ --i;
+ }
}
}
// misc initialization stuff
//----------------------------------------------------------------------
-#if wxOSX_USE_CARBON && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
-bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec)
-{
- OSStatus err = noErr ;
- bool converted = ConvertEventRefToEventRecord( event, rec) ;
-
- if ( !converted )
- {
- switch ( GetEventClass( event ) )
- {
- case kEventClassKeyboard :
- {
- converted = true ;
- switch ( GetEventKind(event) )
- {
- case kEventRawKeyDown :
- rec->what = keyDown ;
- break ;
-
- case kEventRawKeyRepeat :
- rec->what = autoKey ;
- break ;
-
- case kEventRawKeyUp :
- rec->what = keyUp ;
- break ;
-
- case kEventRawKeyModifiersChanged :
- rec->what = nullEvent ;
- break ;
-
- default :
- converted = false ;
- break ;
- }
-
- if ( converted )
- {
- UInt32 keyCode ;
- unsigned char charCode ;
- UInt32 modifiers ;
- GetMouse( &rec->where) ;
- err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers);
- err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode);
- err = GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode);
- rec->modifiers = modifiers ;
- rec->message = (keyCode << 8 ) + charCode ;
- }
- }
- break ;
-
- case kEventClassTextInput :
- {
- switch ( GetEventKind( event ) )
- {
- case kEventTextInputUnicodeForKeyEvent :
- {
- EventRef rawEvent ;
- err = GetEventParameter(
- event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL,
- sizeof(rawEvent), NULL, &rawEvent ) ;
- converted = true ;
-
- {
- UInt32 keyCode, modifiers;
- unsigned char charCode ;
- GetMouse( &rec->where) ;
- rec->what = keyDown ;
- err = GetEventParameter(rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers);
- err = GetEventParameter(rawEvent, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode);
- err = GetEventParameter(rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode);
- rec->modifiers = modifiers ;
- rec->message = (keyCode << 8 ) + charCode ;
- }
- }
- break ;
-
- default :
- break ;
- }
- }
- break ;
-
- default :
- break ;
- }
- }
-
- return converted ;
-}
-#endif
-
wxApp::wxApp()
{
m_printMode = wxPRINT_WINDOWS;
#if wxOSX_USE_CARBON
long keyval = event.m_keyCode ;
- wxNonOwnedWindow *tlw = focus->MacGetTopLevelWindow() ;
- if (tlw)
{
- event.SetEventType( wxEVT_CHAR_HOOK );
- handled = tlw->HandleWindowEvent( event );
- if ( handled && event.GetSkipped() )
+ wxKeyEvent eventCharHook(wxEVT_CHAR_HOOK, event);
+ handled = focus->HandleWindowEvent( eventCharHook );
+ if ( handled && eventCharHook.IsNextEventAllowed() )
handled = false ;
}
if ( !handled )
{
- event.SetEventType( wxEVT_CHAR );
- event.Skip( false ) ;
handled = focus->HandleWindowEvent( event ) ;
}