diff --git a/Externals/wxWidgets3/include/wx/defs.h b/Externals/wxWidgets3/include/wx/defs.h index e25b1e8a52..9626b9d564 100644 --- a/Externals/wxWidgets3/include/wx/defs.h +++ b/Externals/wxWidgets3/include/wx/defs.h @@ -2333,7 +2333,7 @@ enum wxKeyModifier wxMOD_META = 0x0008, wxMOD_WIN = wxMOD_META, #if defined(__WXMAC__) - wxMOD_RAW_CONTROL = 0x0010, + wxMOD_RAW_CONTROL = 2, #else wxMOD_RAW_CONTROL = wxMOD_CONTROL, #endif diff --git a/Externals/wxWidgets3/src/osx/cocoa/srchctrl.mm b/Externals/wxWidgets3/src/osx/cocoa/srchctrl.mm index 7cf1695285..b146cd526a 100644 --- a/Externals/wxWidgets3/src/osx/cocoa/srchctrl.mm +++ b/Externals/wxWidgets3/src/osx/cocoa/srchctrl.mm @@ -9,6 +9,7 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#import #ifdef __BORLANDC__ #pragma hdrstop @@ -31,6 +32,7 @@ @interface wxNSSearchField : NSSearchField { BOOL m_withinTextDidChange; + NSEvent* lastKeyDownEvent; } @end @@ -63,6 +65,50 @@ - (void)textDidChange:(NSNotification *)aNotification m_withinTextDidChange = NO; } +- (BOOL)textView:(NSTextView *)aTextView + clickedOnLink:(id)link + atIndex:(NSUInteger)charIndex { + wxWidgetCocoaImpl *impl = + (wxWidgetCocoaImpl *)wxWidgetImpl::FindFromWXWidget(aTextView); + if (impl) { + wxWindow *wxpeer = (wxWindow *)impl->GetWXPeer(); + if (wxpeer) { + wxMouseEvent evtMouse(wxEVT_LEFT_DOWN); + wxTextUrlEvent event(wxpeer->GetId(), evtMouse, (long int)charIndex, + (long int)charIndex); + event.SetEventObject(wxpeer); + wxpeer->HandleWindowEvent(event); + } + } + return NO; +} + +- (BOOL)_handleClipboardEvent:(wxEventType)type { + wxWidgetImpl *impl = wxWidgetImpl::FindFromWXWidget(self); + wxWindow *wxpeer = impl ? impl->GetWXPeer() : NULL; + if (wxpeer) { + wxClipboardTextEvent evt(type, wxpeer->GetId()); + evt.SetEventObject(wxpeer); + return wxpeer->HandleWindowEvent(evt); + } + return false; +} + +- (void)copy:(id)sender { + if (![self _handleClipboardEvent:wxEVT_TEXT_COPY]) + [super copy:sender]; +} + +- (void)cut:(id)sender { + if (![self _handleClipboardEvent:wxEVT_TEXT_CUT]) + [super cut:sender]; +} + +- (void)paste:(id)sender { + if (![self _handleClipboardEvent:wxEVT_TEXT_PASTE]) + [super paste:sender]; +} + - (void)controlTextDidChange:(NSNotification *)aNotification { wxUnusedVar(aNotification); @@ -100,6 +146,65 @@ - (BOOL) isWithinTextDidChange return m_withinTextDidChange; } +- (BOOL)control:(NSControl *)control + textView:(NSTextView *)textView + doCommandBySelector:(SEL)commandSelector { + wxUnusedVar(textView); + wxUnusedVar(control); + + BOOL handled = NO; + + // send back key events wx' common code knows how to handle + + wxWidgetCocoaImpl *impl = + (wxWidgetCocoaImpl *)wxWidgetImpl::FindFromWXWidget(self); + if (impl) { + wxWindow *wxpeer = (wxWindow *)impl->GetWXPeer(); + if (wxpeer) { + if (commandSelector == @selector(insertNewline:)) { + [textView insertNewlineIgnoringFieldEditor:self]; + handled = YES; + } else if (commandSelector == @selector(insertTab:)) { + [textView insertTabIgnoringFieldEditor:self]; + handled = YES; + } else if (commandSelector == @selector(insertBacktab:)) { + [textView insertTabIgnoringFieldEditor:self]; + handled = YES; + } else if (commandSelector == @selector(paste:)) { + [self paste:self]; + handled = YES; + } + } + } + + return handled; +} + +- (void)keyDown:(NSEvent *)event { + wxWidgetCocoaImpl *impl = + (wxWidgetCocoaImpl *)wxWidgetImpl::FindFromWXWidget(self); + if (impl) { + wxWindow *wxpeer = (wxWindow *)impl->GetWXPeer(); + if (wxpeer) { + if (impl == NULL || !impl->DoHandleKeyEvent(event)) + [super keyDown:event]; + } + } + +} + +- (void)keyUp:(NSEvent *)event { + wxWidgetCocoaImpl *impl = + (wxWidgetCocoaImpl *)wxWidgetImpl::FindFromWXWidget(self); + if (impl) { + wxWindow *wxpeer = (wxWindow *)impl->GetWXPeer(); + if (wxpeer) { + if (impl == NULL || !impl->DoHandleKeyEvent(event)) + [super keyUp:event]; + } + } +} + @end // ============================================================================ diff --git a/Externals/wxWidgets3/src/osx/cocoa/textctrl.mm b/Externals/wxWidgets3/src/osx/cocoa/textctrl.mm index 1e46578226..c973df8973 100644 --- a/Externals/wxWidgets3/src/osx/cocoa/textctrl.mm +++ b/Externals/wxWidgets3/src/osx/cocoa/textctrl.mm @@ -1582,17 +1582,17 @@ wxWindowID WXUNUSED(id), long WXUNUSED(extraStyle)) { NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; - wxWidgetCocoaImpl* c = NULL; + wxWidgetCocoaImpl*pWxWidgetCocoa = NULL; if ( style & wxTE_MULTILINE ) { wxNSTextScrollView* v = nil; v = [[wxNSTextScrollView alloc] initWithFrame:r]; - wxNSTextViewControl* t = new wxNSTextViewControl( wxpeer, v, style ); - c = t; - c->SetNeedsFocusRect( true ); + wxNSTextViewControl* textVControl = new wxNSTextViewControl( wxpeer, v, style ); + pWxWidgetCocoa = textVControl; + pWxWidgetCocoa->SetNeedsFocusRect( true ); - t->SetStringValue(str); + textVControl->SetStringValue(str); } else { @@ -1616,7 +1616,7 @@ long WXUNUSED(extraStyle)) [cell setScrollable:YES]; wxNSTextFieldControl* t = new wxNSTextFieldControl( wxpeer, wxpeer, v ); - c = t; + pWxWidgetCocoa = t; if ( (style & wxNO_BORDER) || (style & wxSIMPLE_BORDER) ) { @@ -1629,13 +1629,13 @@ long WXUNUSED(extraStyle)) else { // use native border - c->SetNeedsFrame(false); + pWxWidgetCocoa->SetNeedsFrame(false); } t->SetStringValue(str); } - return c; + return pWxWidgetCocoa; } diff --git a/Externals/wxWidgets3/src/osx/srchctrl_osx.cpp b/Externals/wxWidgets3/src/osx/srchctrl_osx.cpp index fa3101f42e..8b967eaf3a 100644 --- a/Externals/wxWidgets3/src/osx/srchctrl_osx.cpp +++ b/Externals/wxWidgets3/src/osx/srchctrl_osx.cpp @@ -27,6 +27,7 @@ #include "wx/osx/private.h" wxBEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase) +EVT_KEY_UP(wxTextCtrl::OnKeyDown) wxEND_EVENT_TABLE() wxIMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase); diff --git a/Externals/wxWidgets3/src/osx/textctrl_osx.cpp b/Externals/wxWidgets3/src/osx/textctrl_osx.cpp index cdf998c5c6..34c1d0202d 100644 --- a/Externals/wxWidgets3/src/osx/textctrl_osx.cpp +++ b/Externals/wxWidgets3/src/osx/textctrl_osx.cpp @@ -361,9 +361,23 @@ void wxTextCtrl::OnKeyDown(wxKeyEvent& event) if ( CanCut() ) Cut() ; return; - default: + case 'Z': + if ( GetTextPeer() && GetTextPeer()->CanUndo() ) + GetTextPeer()->Undo() ; + return; + default: break; } + } else if (event.GetModifiers() == wxMOD_CONTROL & wxMOD_SHIFT) { + switch( event.GetKeyCode() ) + { + case 'Z': + if ( GetTextPeer() && GetTextPeer()->CanRedo() ) + GetTextPeer()->Redo() ; + return; + default: + break; + } } // no, we didn't process it event.Skip(); @@ -672,7 +686,8 @@ void wxTextWidgetImpl::Clear() bool wxTextWidgetImpl::CanUndo() const { - return false ; +// printf("CAN UNDO\n"); + return false ; } void wxTextWidgetImpl::Undo()