Merge branch 'mac-fixes'
Miscellaneous fixes for wxOSX. See https://github.com/wxWidgets/wxWidgets/pull/2185
This commit is contained in:
@@ -1937,6 +1937,57 @@ outlineView:(NSOutlineView*)outlineView
|
||||
dvc->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
-(void) sendEditingDoneEvent:(BOOL)isCancelled
|
||||
{
|
||||
// under OSX an event indicating the end of an editing session can be sent
|
||||
// even if no event indicating a start of an editing session has been sent
|
||||
// (see Documentation for NSControl controlTextDidEndEditing:); this is
|
||||
// not expected by a user of the wxWidgets library and therefore an
|
||||
// wxEVT_DATAVIEW_ITEM_EDITING_DONE event is only sent if a
|
||||
// corresponding wxEVT_DATAVIEW_ITEM_EDITING_STARTED has been sent
|
||||
// before; to check if a wxEVT_DATAVIEW_ITEM_EDITING_STARTED has
|
||||
// been sent the last edited column/row are valid:
|
||||
if ( currentlyEditedColumn != -1 && currentlyEditedRow != -1 )
|
||||
{
|
||||
NSTableColumn*
|
||||
tableColumn = [[self tableColumns] objectAtIndex:currentlyEditedColumn];
|
||||
wxDataViewColumn* const
|
||||
col([static_cast<wxDVCNSTableColumn*>(tableColumn) getColumnPointer]);
|
||||
|
||||
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
|
||||
|
||||
const wxDataViewItem
|
||||
item = wxDataViewItemFromItem([self itemAtRow:currentlyEditedRow]);
|
||||
|
||||
// send event to wxWidgets:
|
||||
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EDITING_DONE, dvc, col, item);
|
||||
if ( isCancelled )
|
||||
event.SetEditCancelled();
|
||||
|
||||
dvc->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
// we're not editing any more
|
||||
currentlyEditedColumn =
|
||||
currentlyEditedRow = -1;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) editColumn:(NSInteger)column row:(NSInteger)row withEvent:(NSEvent*)event select:(BOOL)select
|
||||
{
|
||||
[super editColumn:column row:row withEvent:event select:select];
|
||||
|
||||
currentlyEditedColumn = column;
|
||||
currentlyEditedRow = row;
|
||||
}
|
||||
|
||||
-(void) cancelOperation:(id)sender
|
||||
{
|
||||
[self abortEditing];
|
||||
[[self window] makeFirstResponder:self];
|
||||
|
||||
[self sendEditingDoneEvent:YES];
|
||||
}
|
||||
|
||||
-(BOOL) textShouldBeginEditing:(NSText*)textEditor
|
||||
{
|
||||
wxUnusedVar(textEditor);
|
||||
@@ -2007,35 +2058,7 @@ outlineView:(NSOutlineView*)outlineView
|
||||
// have the checks for IsDeleting() in several other methods of this class.
|
||||
[super textDidEndEditing:notification];
|
||||
|
||||
// under OSX an event indicating the end of an editing session can be sent
|
||||
// even if no event indicating a start of an editing session has been sent
|
||||
// (see Documentation for NSControl controlTextDidEndEditing:); this is
|
||||
// not expected by a user of the wxWidgets library and therefore an
|
||||
// wxEVT_DATAVIEW_ITEM_EDITING_DONE event is only sent if a
|
||||
// corresponding wxEVT_DATAVIEW_ITEM_EDITING_STARTED has been sent
|
||||
// before; to check if a wxEVT_DATAVIEW_ITEM_EDITING_STARTED has
|
||||
// been sent the last edited column/row are valid:
|
||||
if ( currentlyEditedColumn != -1 && currentlyEditedRow != -1 )
|
||||
{
|
||||
NSTableColumn*
|
||||
tableColumn = [[self tableColumns] objectAtIndex:currentlyEditedColumn];
|
||||
wxDataViewColumn* const
|
||||
col([static_cast<wxDVCNSTableColumn*>(tableColumn) getColumnPointer]);
|
||||
|
||||
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
|
||||
|
||||
const wxDataViewItem
|
||||
item = wxDataViewItemFromItem([self itemAtRow:currentlyEditedRow]);
|
||||
|
||||
// send event to wxWidgets:
|
||||
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EDITING_DONE, dvc, col, item);
|
||||
dvc->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
|
||||
// we're not editing any more
|
||||
currentlyEditedColumn =
|
||||
currentlyEditedRow = -1;
|
||||
}
|
||||
[self sendEditingDoneEvent:NO];
|
||||
}
|
||||
|
||||
-(BOOL) becomeFirstResponder
|
||||
|
@@ -335,8 +335,20 @@ extern int wxOSXGetIdFromSelector(SEL action );
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) triggerMenu:(SEL) action
|
||||
- (BOOL) triggerMenu:(SEL) action sender:(id)sender
|
||||
{
|
||||
// feed back into menu item, if it is ours
|
||||
if ( [sender isKindOfClass:wxNSMenuItem.class] )
|
||||
{
|
||||
wxNSMenuItem* nsMenuItem = (wxNSMenuItem*) sender;
|
||||
wxMenuItemImpl* impl = [nsMenuItem implementation];
|
||||
if ( impl )
|
||||
{
|
||||
wxMenuItem* menuitem = impl->GetWXPeer();
|
||||
return menuitem->GetMenu()->HandleCommandProcess(menuitem);
|
||||
}
|
||||
}
|
||||
// otherwise feed back command into common menubar
|
||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
|
||||
if ( mbar )
|
||||
{
|
||||
@@ -369,43 +381,43 @@ extern int wxOSXGetIdFromSelector(SEL action );
|
||||
- (void)undo:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)redo:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)cut:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)copy:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)selectAll:(id)sender
|
||||
{
|
||||
wxUnusedVar(sender);
|
||||
[self triggerMenu:_cmd];
|
||||
[self triggerMenu:_cmd sender:sender];
|
||||
}
|
||||
|
||||
- (void)windowDidMiniaturize:(NSNotification *)notification
|
||||
|
@@ -3094,12 +3094,11 @@ bool wxWidgetCocoaImpl::CanFocus() const
|
||||
{
|
||||
if ( !IsVisible() )
|
||||
{
|
||||
// It's useless to call canBecomeKeyView in this case, it will always
|
||||
// return false. Try to return something reasonable ourselves, knowing
|
||||
// that most controls are not focusable when full keyboard access if
|
||||
// off and wxNSTextViewControl overrides CanFocus() to always return
|
||||
// true anyhow.
|
||||
return [NSApp isFullKeyboardAccessEnabled];
|
||||
// canBecomeKeyView always returns false for hidden windows, but this
|
||||
// could be wrong because the window could still accept focus once it
|
||||
// becomes visible, so we have no choice but to return true here to
|
||||
// avoid situations in which the expected window doesn't get the focus.
|
||||
return true;
|
||||
}
|
||||
|
||||
NSView* targetView = m_osxView;
|
||||
@@ -3712,7 +3711,7 @@ bool wxWidgetCocoaImpl::DoHandleKeyNavigation(const wxKeyEvent &event)
|
||||
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||
new_event.SetWindowChange( event.ControlDown() );
|
||||
new_event.SetCurrentFocus( focus );
|
||||
handled = iter->HandleWindowEvent( new_event ) && !new_event.GetSkipped();
|
||||
handled = iter->HandleWindowEvent( new_event );
|
||||
}
|
||||
|
||||
iter = iter->GetParent() ;
|
||||
|
@@ -2568,12 +2568,11 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
: "unknown",
|
||||
wxDumpWindow(this));
|
||||
|
||||
bool handled = false;
|
||||
|
||||
// moved the ordinary key event sending AFTER the accel evaluation
|
||||
if ( HandleWindowEvent(event) )
|
||||
return true;
|
||||
|
||||
#if wxUSE_ACCEL
|
||||
if (event.GetEventType() == wxEVT_KEY_DOWN)
|
||||
if (event.GetEventType() == wxEVT_CHAR_HOOK)
|
||||
{
|
||||
wxWindow *ancestor = this;
|
||||
while (ancestor)
|
||||
@@ -2584,16 +2583,16 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
wxEvtHandler * const handler = ancestor->GetEventHandler();
|
||||
|
||||
wxCommandEvent command_event( wxEVT_MENU, command );
|
||||
handled = handler->ProcessEvent( command_event );
|
||||
|
||||
if ( !handled )
|
||||
if ( !handler->ProcessEvent( command_event ) )
|
||||
{
|
||||
// accelerators can also be used with buttons, try them too
|
||||
command_event.SetEventType(wxEVT_BUTTON);
|
||||
handled = handler->ProcessEvent( command_event );
|
||||
handler->ProcessEvent( command_event );
|
||||
}
|
||||
|
||||
break;
|
||||
// In any case, the event was handled as it triggered an
|
||||
// accelerator.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ancestor->IsTopNavigationDomain(wxWindow::Navigation_Accel))
|
||||
@@ -2604,14 +2603,7 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
}
|
||||
#endif // wxUSE_ACCEL
|
||||
|
||||
if ( !handled )
|
||||
{
|
||||
handled = HandleWindowEvent( event ) ;
|
||||
if ( handled && event.GetSkipped() )
|
||||
handled = false ;
|
||||
}
|
||||
|
||||
return handled ;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
Reference in New Issue
Block a user