refactoring to common code for updating selections, using common focus code, see #14269
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76576 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,7 +48,7 @@ public :
|
|||||||
virtual bool resignFirstResponder(WXWidget slf, void *_cmd);
|
virtual bool resignFirstResponder(WXWidget slf, void *_cmd);
|
||||||
|
|
||||||
virtual void SetInternalSelection( long from , long to );
|
virtual void SetInternalSelection( long from , long to );
|
||||||
|
virtual void UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* editor);
|
||||||
protected :
|
protected :
|
||||||
NSTextField* m_textField;
|
NSTextField* m_textField;
|
||||||
long m_selStart;
|
long m_selStart;
|
||||||
|
@@ -90,6 +90,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)controlTextDidEndEditing:(NSNotification *) aNotification
|
||||||
|
{
|
||||||
|
wxUnusedVar(aNotification);
|
||||||
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
|
if ( impl )
|
||||||
|
{
|
||||||
|
wxNSTextFieldControl* timpl = dynamic_cast<wxNSTextFieldControl*>(impl);
|
||||||
|
if ( timpl )
|
||||||
|
timpl->UpdateInternalSelectionFromEditor(fieldEditor);
|
||||||
|
impl->DoNotifyFocusLost();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)comboBoxWillPopUp:(NSNotification *)notification
|
- (void)comboBoxWillPopUp:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
wxUnusedVar(notification);
|
wxUnusedVar(notification);
|
||||||
|
@@ -196,13 +196,7 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
|||||||
wxUnusedVar(aNotification);
|
wxUnusedVar(aNotification);
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
if ( impl )
|
if ( impl )
|
||||||
{
|
impl->DoNotifyFocusLost();
|
||||||
NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
|
|
||||||
NSView* otherView = wxOSXGetViewFromResponder(responder);
|
|
||||||
|
|
||||||
wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
|
|
||||||
impl->DoNotifyFocusEvent( false, otherWindow );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector
|
- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector
|
||||||
@@ -359,13 +353,7 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
|||||||
|
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
if ( impl )
|
if ( impl )
|
||||||
{
|
impl->DoNotifyFocusLost();
|
||||||
NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
|
|
||||||
NSView* otherView = wxOSXGetViewFromResponder(responder);
|
|
||||||
|
|
||||||
wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
|
|
||||||
impl->DoNotifyFocusEvent( false, otherWindow );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -528,17 +516,9 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
|||||||
if ( impl )
|
if ( impl )
|
||||||
{
|
{
|
||||||
wxNSTextFieldControl* timpl = dynamic_cast<wxNSTextFieldControl*>(impl);
|
wxNSTextFieldControl* timpl = dynamic_cast<wxNSTextFieldControl*>(impl);
|
||||||
if ( fieldEditor )
|
if ( timpl )
|
||||||
{
|
timpl->UpdateInternalSelectionFromEditor(fieldEditor);
|
||||||
NSRange range = [fieldEditor selectedRange];
|
impl->DoNotifyFocusLost();
|
||||||
timpl->SetInternalSelection(range.location, range.location + range.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
|
|
||||||
NSView* otherView = wxOSXGetViewFromResponder(responder);
|
|
||||||
|
|
||||||
wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
|
|
||||||
impl->DoNotifyFocusEvent( false, otherWindow );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
@@ -967,6 +947,15 @@ void wxNSTextFieldControl::SetInternalSelection( long from , long to )
|
|||||||
m_selEnd = to;
|
m_selEnd = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNSTextFieldControl::UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* fieldEditor )
|
||||||
|
{
|
||||||
|
if ( fieldEditor )
|
||||||
|
{
|
||||||
|
NSRange range = [fieldEditor selectedRange];
|
||||||
|
SetInternalSelection(range.location, range.location + range.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// as becoming first responder on a window - triggers a resign on the same control, we have to avoid
|
// as becoming first responder on a window - triggers a resign on the same control, we have to avoid
|
||||||
// the resign notification writing back native selection values before we can set our own
|
// the resign notification writing back native selection values before we can set our own
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user