reducing key event handling complexity
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62149 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -150,7 +150,6 @@ public :
|
|||||||
virtual void UpdateLineToEnd( unsigned int n);
|
virtual void UpdateLineToEnd( unsigned int n);
|
||||||
|
|
||||||
virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
|
virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
|
||||||
virtual bool DoHandleKeyEvent(NSEvent *event);
|
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
wxNSTableView* m_tableView ;
|
wxNSTableView* m_tableView ;
|
||||||
@@ -512,18 +511,6 @@ void wxListWidgetCocoaImpl::controlDoubleAction(WXWidget WXUNUSED(slf),void* WXU
|
|||||||
list->HandleLineEvent( sel, true );
|
list->HandleLineEvent( sel, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
|
||||||
{
|
|
||||||
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
|
||||||
SetupKeyEvent( wxevent, event );
|
|
||||||
wxevent.SetEventObject(GetWXPeer());
|
|
||||||
bool result = GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
|
||||||
|
|
||||||
// no interpretKeyEvents here, but rerouting to native keyhandling
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// accessing content
|
// accessing content
|
||||||
|
|
||||||
|
|
||||||
|
@@ -416,8 +416,10 @@ void wxNSTextViewControl::WriteText(const wxString& str)
|
|||||||
wxString st = str;
|
wxString st = str;
|
||||||
wxMacConvertNewlines10To13( &st );
|
wxMacConvertNewlines10To13( &st );
|
||||||
wxMacEditHelper helper(m_textView);
|
wxMacEditHelper helper(m_textView);
|
||||||
|
NSEvent* formerEvent = m_lastKeyDownEvent;
|
||||||
|
m_lastKeyDownEvent = nil;
|
||||||
[m_textView insertText:wxCFStringRef( st , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
[m_textView insertText:wxCFStringRef( st , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||||
|
m_lastKeyDownEvent = formerEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNSTextViewControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack )
|
void wxNSTextViewControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack )
|
||||||
@@ -538,6 +540,8 @@ void wxNSTextFieldControl::SetSelection( long from , long to )
|
|||||||
|
|
||||||
void wxNSTextFieldControl::WriteText(const wxString& str)
|
void wxNSTextFieldControl::WriteText(const wxString& str)
|
||||||
{
|
{
|
||||||
|
NSEvent* formerEvent = m_lastKeyDownEvent;
|
||||||
|
m_lastKeyDownEvent = nil;
|
||||||
NSText* editor = [m_textField currentEditor];
|
NSText* editor = [m_textField currentEditor];
|
||||||
if ( editor )
|
if ( editor )
|
||||||
{
|
{
|
||||||
@@ -554,6 +558,7 @@ void wxNSTextFieldControl::WriteText(const wxString& str)
|
|||||||
SetStringValue( val ) ;
|
SetStringValue( val ) ;
|
||||||
SetSelection( start + str.length() , start + str.length() ) ;
|
SetSelection( start + str.length() , start + str.length() ) ;
|
||||||
}
|
}
|
||||||
|
m_lastKeyDownEvent = formerEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNSTextFieldControl::controlAction(WXWidget WXUNUSED(slf),
|
void wxNSTextFieldControl::controlAction(WXWidget WXUNUSED(slf),
|
||||||
|
@@ -881,11 +881,14 @@ void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
|
|||||||
|
|
||||||
void wxWidgetCocoaImpl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
|
void wxWidgetCocoaImpl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
|
||||||
{
|
{
|
||||||
|
if ( [event type] == NSKeyDown )
|
||||||
|
m_lastKeyDownEvent = event;
|
||||||
if ( GetFocusedViewInWindow([slf window]) != slf || m_hasEditor || !DoHandleKeyEvent(event) )
|
if ( GetFocusedViewInWindow([slf window]) != slf || m_hasEditor || !DoHandleKeyEvent(event) )
|
||||||
{
|
{
|
||||||
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
||||||
superimpl(slf, (SEL)_cmd, event);
|
superimpl(slf, (SEL)_cmd, event);
|
||||||
}
|
}
|
||||||
|
m_lastKeyDownEvent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::insertText(NSString* text, WXWidget slf, void *_cmd)
|
void wxWidgetCocoaImpl::insertText(NSString* text, WXWidget slf, void *_cmd)
|
||||||
@@ -895,7 +898,6 @@ void wxWidgetCocoaImpl::insertText(NSString* text, WXWidget slf, void *_cmd)
|
|||||||
wxOSX_TextEventHandlerPtr superimpl = (wxOSX_TextEventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
wxOSX_TextEventHandlerPtr superimpl = (wxOSX_TextEventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
||||||
superimpl(slf, (SEL)_cmd, text);
|
superimpl(slf, (SEL)_cmd, text);
|
||||||
}
|
}
|
||||||
m_lastKeyDownEvent = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1578,9 +1580,9 @@ bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
|||||||
|
|
||||||
// this will fire higher level events, like insertText, to help
|
// this will fire higher level events, like insertText, to help
|
||||||
// us handle EVT_CHAR, etc.
|
// us handle EVT_CHAR, etc.
|
||||||
if ( !m_hasEditor && [event type] == NSKeyDown)
|
|
||||||
|
if ( m_wxPeer->MacIsUserPane() && [event type] == NSKeyDown)
|
||||||
{
|
{
|
||||||
m_lastKeyDownEvent = event;
|
|
||||||
if ( !result )
|
if ( !result )
|
||||||
{
|
{
|
||||||
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
||||||
@@ -1590,6 +1592,7 @@ bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
|||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user