mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 22:31:56 +00:00
Implement menu and user interface item validation for NSTextView. The
list of validated actions is incomplete but at least includes all items from a standard Edit menu. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29012 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
036a78c32d
commit
84a6777ed7
2 changed files with 55 additions and 0 deletions
|
@ -1,5 +1,11 @@
|
||||||
2009-11-14 Wolfgang Lux <wolfgang.lux@gmail.com>
|
2009-11-14 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSTextView_actions.m (-validateMenuItem:,
|
||||||
|
-validateUserIntefaceItem:): Implement menu and user interface
|
||||||
|
item validation for NSTextView. The list of validated actions is
|
||||||
|
incomplete but at least includes all items from a standard Edit
|
||||||
|
menu.
|
||||||
|
|
||||||
* Source/NSCell.m(-_setupTextWithFrame:inView:editor:delegate:range:,
|
* Source/NSCell.m(-_setupTextWithFrame:inView:editor:delegate:range:,
|
||||||
-_updateFieldEditor):
|
-_updateFieldEditor):
|
||||||
* Source/NSActionCell.m (-setObjectValue:, -setStringValue:):
|
* Source/NSActionCell.m (-setObjectValue:, -setStringValue:):
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
#include "AppKit/NSAttributedString.h"
|
#include "AppKit/NSAttributedString.h"
|
||||||
#include "AppKit/NSGraphics.h"
|
#include "AppKit/NSGraphics.h"
|
||||||
#include "AppKit/NSLayoutManager.h"
|
#include "AppKit/NSLayoutManager.h"
|
||||||
|
#include "AppKit/NSMenuItem.h"
|
||||||
|
#include "AppKit/NSPasteboard.h"
|
||||||
#include "AppKit/NSScrollView.h"
|
#include "AppKit/NSScrollView.h"
|
||||||
#include "AppKit/NSTextStorage.h"
|
#include "AppKit/NSTextStorage.h"
|
||||||
#include "AppKit/NSTextView.h"
|
#include "AppKit/NSTextView.h"
|
||||||
|
@ -1512,4 +1514,51 @@ and layout is left-to-right */
|
||||||
// FIXME
|
// FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) validateMenuItem: (NSMenuItem *)item
|
||||||
|
{
|
||||||
|
return [self validateUserInterfaceItem: item];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) validateUserInterfaceItem: (id<NSValidatedUserInterfaceItem>)item
|
||||||
|
{
|
||||||
|
SEL action = [item action];
|
||||||
|
|
||||||
|
// FIXME The list of validated actions below is far from complete
|
||||||
|
|
||||||
|
if (sel_eq(action, @selector(cut:)) || sel_eq(action, @selector(delete:)))
|
||||||
|
return [self isEditable] && [self selectedRange].length > 0;
|
||||||
|
|
||||||
|
if (sel_eq(action, @selector(copy:)))
|
||||||
|
return [self selectedRange].length > 0;
|
||||||
|
|
||||||
|
if (sel_eq(action, @selector(paste:))
|
||||||
|
|| sel_eq(action, @selector(pasteAsPlainText:))
|
||||||
|
|| sel_eq(action, @selector(pasteAsRichText:)))
|
||||||
|
{
|
||||||
|
if ([self isEditable])
|
||||||
|
{
|
||||||
|
NSArray *types;
|
||||||
|
NSString *available;
|
||||||
|
|
||||||
|
if (sel_eq(action, @selector(paste:)))
|
||||||
|
types = [self readablePasteboardTypes];
|
||||||
|
else if (sel_eq(action, @selector(pasteAsPlainText:)))
|
||||||
|
types = [NSArray arrayWithObject: NSStringPboardType];
|
||||||
|
else /*if (sel_eq(action, @selector(pasteAsRichText:)))*/
|
||||||
|
types = [NSArray arrayWithObject: NSRTFPboardType];
|
||||||
|
|
||||||
|
available = [[NSPasteboard generalPasteboard]
|
||||||
|
availableTypeFromArray: types];
|
||||||
|
return available != nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sel_eq(action, @selector(selectAll:))
|
||||||
|
|| sel_eq(action, @selector(centerSelectionInVisibleArea:)))
|
||||||
|
return [self isSelectable];
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue