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:
parent
2b99f92872
commit
e65104f198
@ -48,7 +48,7 @@ public :
|
||||
virtual bool resignFirstResponder(WXWidget slf, void *_cmd);
|
||||
|
||||
virtual void SetInternalSelection( long from , long to );
|
||||
|
||||
virtual void UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* editor);
|
||||
protected :
|
||||
NSTextField* m_textField;
|
||||
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
|
||||
{
|
||||
wxUnusedVar(notification);
|
||||
|
@ -196,13 +196,7 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
||||
wxUnusedVar(aNotification);
|
||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
if ( impl )
|
||||
{
|
||||
NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
|
||||
NSView* otherView = wxOSXGetViewFromResponder(responder);
|
||||
|
||||
wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
|
||||
impl->DoNotifyFocusEvent( false, otherWindow );
|
||||
}
|
||||
impl->DoNotifyFocusLost();
|
||||
}
|
||||
|
||||
- (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 );
|
||||
if ( impl )
|
||||
{
|
||||
NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
|
||||
NSView* otherView = wxOSXGetViewFromResponder(responder);
|
||||
|
||||
wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
|
||||
impl->DoNotifyFocusEvent( false, otherWindow );
|
||||
}
|
||||
impl->DoNotifyFocusLost();
|
||||
}
|
||||
|
||||
@end
|
||||
@ -528,17 +516,9 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
||||
if ( impl )
|
||||
{
|
||||
wxNSTextFieldControl* timpl = dynamic_cast<wxNSTextFieldControl*>(impl);
|
||||
if ( fieldEditor )
|
||||
{
|
||||
NSRange range = [fieldEditor selectedRange];
|
||||
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 );
|
||||
if ( timpl )
|
||||
timpl->UpdateInternalSelectionFromEditor(fieldEditor);
|
||||
impl->DoNotifyFocusLost();
|
||||
}
|
||||
}
|
||||
@end
|
||||
@ -967,6 +947,15 @@ void wxNSTextFieldControl::SetInternalSelection( long from , long 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
|
||||
// the resign notification writing back native selection values before we can set our own
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user