]> git.saurik.com Git - wxWidgets.git/commitdiff
textcontrol handling change for mac (execute event in mid stream)
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 17 Aug 2003 19:41:16 +0000 (19:41 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 17 Aug 2003 19:41:16 +0000 (19:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22977 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/app.cpp
src/mac/carbon/app.cpp
src/mac/carbon/textctrl.cpp
src/mac/carbon/toplevel.cpp
src/mac/textctrl.cpp
src/mac/toplevel.cpp

index fd5c1b0d4f27084b82632c002cd13d8efb791a49..4d20f6ee2719efb1d543cae14c86f47f085b7d67 100644 (file)
@@ -972,6 +972,9 @@ wxApp::wxApp()
 {
   m_printMode = wxPRINT_WINDOWS;
   m_auto3D = TRUE;
 {
   m_printMode = wxPRINT_WINDOWS;
   m_auto3D = TRUE;
+
+  m_macCurrentEvent = NULL ;
+  m_macCurrentEventHandlerCallRef = NULL ;
 }
 
 bool wxApp::Initialized()
 }
 
 bool wxApp::Initialized()
@@ -1692,6 +1695,8 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
 
         if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
         {
 
         if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
         {
+#if 0
+            // we must handle control keys the other way round, otherwise text content is updated too late
             // has not been handled -> perform default
             wxControl* control = wxDynamicCast( focus , wxControl ) ;
             if ( control &&  control->GetMacControl() != NULL )
             // has not been handled -> perform default
             wxControl* control = wxDynamicCast( focus , wxControl ) ;
             if ( control &&  control->GetMacControl() != NULL )
@@ -1702,6 +1707,7 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
                 keycode = short(ev->message & keyCodeMask) >> 8 ;
                 ::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
             }
                 keycode = short(ev->message & keyCodeMask) >> 8 ;
                 ::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
             }
+#endif
         }
     }
 }
         }
     }
 }
index fd5c1b0d4f27084b82632c002cd13d8efb791a49..4d20f6ee2719efb1d543cae14c86f47f085b7d67 100644 (file)
@@ -972,6 +972,9 @@ wxApp::wxApp()
 {
   m_printMode = wxPRINT_WINDOWS;
   m_auto3D = TRUE;
 {
   m_printMode = wxPRINT_WINDOWS;
   m_auto3D = TRUE;
+
+  m_macCurrentEvent = NULL ;
+  m_macCurrentEventHandlerCallRef = NULL ;
 }
 
 bool wxApp::Initialized()
 }
 
 bool wxApp::Initialized()
@@ -1692,6 +1695,8 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
 
         if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
         {
 
         if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
         {
+#if 0
+            // we must handle control keys the other way round, otherwise text content is updated too late
             // has not been handled -> perform default
             wxControl* control = wxDynamicCast( focus , wxControl ) ;
             if ( control &&  control->GetMacControl() != NULL )
             // has not been handled -> perform default
             wxControl* control = wxDynamicCast( focus , wxControl ) ;
             if ( control &&  control->GetMacControl() != NULL )
@@ -1702,6 +1707,7 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
                 keycode = short(ev->message & keyCodeMask) >> 8 ;
                 ::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
             }
                 keycode = short(ev->message & keyCodeMask) >> 8 ;
                 ::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
             }
+#endif
         }
     }
 }
         }
     }
 }
index 59a905aeceacbf373f2db12197ae4dd2697cb905..b79f2fc5d377c050a9007b55084167f8aee4b619 100644 (file)
@@ -575,6 +575,13 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle )
         kTXNSystemDefaultEncoding,
         &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
 
         kTXNSystemDefaultEncoding,
         &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
 
+    if ( (wxStyle & wxTE_MULTILINE) && (wxStyle & wxTE_DONTWRAP) )
+    {
+        TXNControlTag tag = kTXNWordWrapStateTag ;
+        TXNControlData dat ;
+        dat.uValue = kTXNNoAutoWrap ;
+        TXNSetTXNObjectControls( varsp->fTXNRec , false , 1 , &tag , &dat ) ;
+    }
         Str255 fontName ;
         SInt16 fontSize ;
         Style fontStyle ;
         Str255 fontName ;
         SInt16 fontSize ;
         Style fontStyle ;
@@ -1591,8 +1598,25 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
 
     if (!eat_key)
     {
 
     if (!eat_key)
     {
-        // default handling
-        event.Skip() ;
+        // perform keystroke handling
+#if TARGET_CARBON
+        if ( m_macUsesTXN && wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
+            CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
+        else 
+#endif
+        {
+            EventRecord rec ;
+            if ( wxMacConvertEventToRecord(  (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) )
+            {
+                EventRecord *ev = &rec ;
+                short keycode ;
+                short keychar ;
+                keychar = short(ev->message & charCodeMask);
+                keycode = short(ev->message & keyCodeMask) >> 8 ;
+
+                ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
+            }
+        }
     }
     if ( ( key >= 0x20 && key < WXK_START ) ||
          key == WXK_RETURN ||
     }
     if ( ( key >= 0x20 && key < WXK_START ) ||
          key == WXK_RETURN ||
index db124d622c496559947c4782fc5929fbe255a670..1e188494c53b3eaf71d71d3f2d44d538d6bdcbcc 100644 (file)
@@ -176,11 +176,15 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
     {
         case kEventRawKeyRepeat :
         case kEventRawKeyDown :
     {
         case kEventRawKeyRepeat :
         case kEventRawKeyDown :
+            WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
+            WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
+            wxTheApp->MacSetCurrentEvent( event , handler ) ;
             if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
                 focus , message , modifiers , when , point.h , point.v ) )
             {
                 result = noErr ;
             }
             if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
                 focus , message , modifiers , when , point.h , point.v ) )
             {
                 result = noErr ;
             }
+            wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
             break ;
         case kEventRawKeyUp :
             if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
             break ;
         case kEventRawKeyUp :
             if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
index 59a905aeceacbf373f2db12197ae4dd2697cb905..b79f2fc5d377c050a9007b55084167f8aee4b619 100644 (file)
@@ -575,6 +575,13 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle )
         kTXNSystemDefaultEncoding,
         &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
 
         kTXNSystemDefaultEncoding,
         &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
 
+    if ( (wxStyle & wxTE_MULTILINE) && (wxStyle & wxTE_DONTWRAP) )
+    {
+        TXNControlTag tag = kTXNWordWrapStateTag ;
+        TXNControlData dat ;
+        dat.uValue = kTXNNoAutoWrap ;
+        TXNSetTXNObjectControls( varsp->fTXNRec , false , 1 , &tag , &dat ) ;
+    }
         Str255 fontName ;
         SInt16 fontSize ;
         Style fontStyle ;
         Str255 fontName ;
         SInt16 fontSize ;
         Style fontStyle ;
@@ -1591,8 +1598,25 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
 
     if (!eat_key)
     {
 
     if (!eat_key)
     {
-        // default handling
-        event.Skip() ;
+        // perform keystroke handling
+#if TARGET_CARBON
+        if ( m_macUsesTXN && wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
+            CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
+        else 
+#endif
+        {
+            EventRecord rec ;
+            if ( wxMacConvertEventToRecord(  (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) )
+            {
+                EventRecord *ev = &rec ;
+                short keycode ;
+                short keychar ;
+                keychar = short(ev->message & charCodeMask);
+                keycode = short(ev->message & keyCodeMask) >> 8 ;
+
+                ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
+            }
+        }
     }
     if ( ( key >= 0x20 && key < WXK_START ) ||
          key == WXK_RETURN ||
     }
     if ( ( key >= 0x20 && key < WXK_START ) ||
          key == WXK_RETURN ||
index db124d622c496559947c4782fc5929fbe255a670..1e188494c53b3eaf71d71d3f2d44d538d6bdcbcc 100644 (file)
@@ -176,11 +176,15 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
     {
         case kEventRawKeyRepeat :
         case kEventRawKeyDown :
     {
         case kEventRawKeyRepeat :
         case kEventRawKeyDown :
+            WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
+            WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
+            wxTheApp->MacSetCurrentEvent( event , handler ) ;
             if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
                 focus , message , modifiers , when , point.h , point.v ) )
             {
                 result = noErr ;
             }
             if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
                 focus , message , modifiers , when , point.h , point.v ) )
             {
                 result = noErr ;
             }
+            wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
             break ;
         case kEventRawKeyUp :
             if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
             break ;
         case kEventRawKeyUp :
             if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(