#987 Cocoa user interface validation

Completed
closed
nobody
None
5
2014-03-07
2013-04-22
chinhster
No

The InnerView class implements responder actions such as cut:, copy:, paste:, undo:, redo: but does not enable/disable user interface items such as a menu item or a toolbar item that have those action methods set. So menu items such as Edit > Undo, Edit > Redo are always enabled when they shouldn't be and Copy is always enabled even when there's no selection. All that's needed is for the following to be added to ScintillaView.mm,

  • (BOOL) validateUserInterfaceItem: (id < NSValidatedUserInterfaceItem >) anItem
    {
    SEL action = [anItem action];

if (action==@selector(undo:)) {
return [self canUndo];
}
else if (action==@selector(redo:)) {
return [self canRedo];
}
else if (action==@selector(cut:) || action==@selector(copy:) || action==@selector(clear:)) {
return mOwner.backend->HasSelection();
}
else if (action==@selector(paste:)) {
return mOwner.backend->CanPaste();
}

return YES;
}

You'll notice that I also handle clear: which is simply,

  • (void) clear: (id) sender
    {
    [self deleteBackward:sender];
    }

Discussion

  • Neil Hodgson

    Neil Hodgson - 2013-05-28
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks