mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Varioyus patches by N. Pero
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4992 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4f9d846b9c
commit
c27b641394
8 changed files with 117 additions and 114 deletions
34
ChangeLog
34
ChangeLog
|
@ -3,6 +3,40 @@ Tue Oct 12 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|||
* Source/NSWorkspace.m: Added private notification center class to
|
||||
handle notifications to be passed between applications.
|
||||
|
||||
Sat Oct 10 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
nextText and previousText can now be safely and almost trivially
|
||||
implemented using the nextKeyView and previousKeyView facilities.
|
||||
Today I did it for NSTextField:
|
||||
* Headers/AppKit/NSTextField.h: Removed ivars nextText and
|
||||
previousText
|
||||
* Source/NSTextField.m ([-encodeWithCoder:]), ([-initWithCoder:]):
|
||||
Update for removal of ivars nextText, previousText.
|
||||
* Model/GMAppKit.m ([NSTextField -initWithModelUnarchiver:]),
|
||||
([NSTextField -encodeWithModelArchiver:]): Updated for removal of
|
||||
ivars.
|
||||
* Source/NSTextField.m ([-nextText]), ([-previousText]),
|
||||
([-setNextText:]), ([-setPreviousText:]): rewritten, by using
|
||||
nextKeyView stuff.
|
||||
* Source/NSTextField.m ([-keyDown:]): Completely rewritten the
|
||||
part before the cell edit.
|
||||
|
||||
A little reorganization of keyboard event handling code written
|
||||
in the last days; added Escape support:
|
||||
* Headers/AppKit/NSApplication.h: Added prototype for
|
||||
-isRunningModalForWindow:.
|
||||
* Source/NSApplication.m ([-isRunningModalForWindow:]): new method
|
||||
(a GNUstep extension). Return YES if there is a modal session
|
||||
running and it is running with the specified window.
|
||||
* Source/NSApplication.m ([-runModalForWindow:]): Close the window
|
||||
on abort.
|
||||
* Source/NSTextField.m ([-keyUp:]): Removed method, useless.
|
||||
* Source/NSView.m ([-keyDown:]): Removed method. Moved the code
|
||||
to [NSWindow -keyDown:].
|
||||
* Source/NSView.m ([-keyUp:]): Removed method, useless.
|
||||
* Source/NSWindow.m ([-keyDown:]): Implemented method. Added
|
||||
Escape support.
|
||||
|
||||
Sat Oct 9 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSButton.m ([-keyDown:]): Perform a click if
|
||||
|
|
|
@ -118,6 +118,7 @@ extern NSString *NSEventTrackingRunLoopMode;
|
|||
- (void) run;
|
||||
- (int) runModalForWindow: (NSWindow*)theWindow;
|
||||
- (int) runModalSession: (NSModalSession)theSession;
|
||||
- (BOOL) isRunningModalForWindow: (NSWindow *)theWindow;
|
||||
- (void) sendEvent: (NSEvent*)theEvent;
|
||||
- (void) stop: (id)sender;
|
||||
- (void) stopModal;
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
@interface NSTextField : NSControl <NSCoding>
|
||||
{
|
||||
// Attributes
|
||||
id next_text;
|
||||
id previous_text;
|
||||
id text_delegate;
|
||||
SEL error_action;
|
||||
NSCursor *text_cursor;
|
||||
|
|
|
@ -916,8 +916,6 @@ void __dummy_GMAppKit_functionForLinking() {}
|
|||
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
|
||||
[archiver encodeBOOL:[self isBordered] withName:@"isBordered"];
|
||||
[archiver encodeBOOL:[self isBezeled] withName:@"isBezeled"];
|
||||
[archiver encodeObject:[self nextText] withName:@"nextText"];
|
||||
[archiver encodeObject:[self previousText] withName:@"previousText"];
|
||||
[archiver encodeObject:[self delegate] withName:@"delegate"];
|
||||
[archiver encodeString:[self stringValue] withName:@"stringValue"];
|
||||
[archiver encodeBOOL:[self isEditable] withName:@"isEditable"];
|
||||
|
@ -940,8 +938,6 @@ void __dummy_GMAppKit_functionForLinking() {}
|
|||
[self setBordered:[unarchiver decodeBOOLWithName:@"isBordered"]];
|
||||
[self setBezeled:[unarchiver decodeBOOLWithName:@"isBezeled"]];
|
||||
|
||||
[self setNextText:[unarchiver decodeObjectWithName:@"nextText"]];
|
||||
[self setPreviousText:[unarchiver decodeObjectWithName:@"previousText"]];
|
||||
[self setDelegate:[unarchiver decodeObjectWithName:@"delegate"]];
|
||||
|
||||
theCell = [self cell];
|
||||
|
|
|
@ -446,10 +446,14 @@ NSApplication *NSApp = nil;
|
|||
{
|
||||
if (theSession)
|
||||
{
|
||||
NSWindow *win_to_close = theSession->window;
|
||||
|
||||
[self endModalSession: theSession];
|
||||
[win_to_close close];
|
||||
}
|
||||
if ([[localException name] isEqual: NSAbortModalException] == NO)
|
||||
[localException raise];
|
||||
|
||||
code = NSRunAbortedResponse;
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
@ -550,6 +554,14 @@ NSApplication *NSApp = nil;
|
|||
return theSession->runState;
|
||||
}
|
||||
|
||||
- (BOOL) isRunningModalForWindow: (NSWindow *)theWindow
|
||||
{
|
||||
if ((session) && (session->window == theWindow))
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) stop: (id)sender
|
||||
{
|
||||
if (session)
|
||||
|
|
|
@ -163,40 +163,22 @@ id _nsTextfieldCellClass = nil;
|
|||
//
|
||||
- (id) nextText
|
||||
{
|
||||
return next_text;
|
||||
return _nextKeyView;
|
||||
}
|
||||
|
||||
- (id) previousText
|
||||
{
|
||||
return previous_text;
|
||||
return _previousKeyView;
|
||||
}
|
||||
|
||||
- (void) setNextText: (id)anObject
|
||||
{
|
||||
id t;
|
||||
|
||||
// Tell the object that we are the previous text Unless it already is
|
||||
next_text = anObject;
|
||||
if ([anObject respondsToSelector: @selector(setPreviousText:)])
|
||||
{
|
||||
t = [anObject previousText];
|
||||
if (t != self)
|
||||
[anObject setPreviousText: self];
|
||||
}
|
||||
[self setNextKeyView: anObject];
|
||||
}
|
||||
|
||||
- (void) setPreviousText: (id)anObject
|
||||
{
|
||||
id t;
|
||||
|
||||
// Tell the object that we are the next text Unless it already knows
|
||||
previous_text = anObject;
|
||||
if ([anObject respondsToSelector: @selector(setNextText:)])
|
||||
{
|
||||
t = [anObject nextText];
|
||||
if (t != self)
|
||||
[anObject setNextText: self];
|
||||
}
|
||||
[self setPreviousKeyView: anObject];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -352,47 +334,39 @@ fprintf(stderr, " TextField mouseDown --- ");
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get characters until you encounter
|
||||
* a carriage return, return number of characters.
|
||||
* Deal with backspaces, etc. Deal with Expose events
|
||||
* on all windows associated with this application.
|
||||
* Deal with keyboard remapping.
|
||||
*/
|
||||
|
||||
// This is called if a key is pressed when an editing session
|
||||
// is not yet started. (If needed, we start it from here).
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
{
|
||||
unsigned int flags = [theEvent modifierFlags];
|
||||
unsigned int key_code = [theEvent keyCode];
|
||||
id nextResponder;
|
||||
|
||||
NSDebugLLog(@"NSText",
|
||||
@"NSTextField: -keyDown %s\n", [[theEvent characters] cString]);
|
||||
|
||||
// If TAB, SHIFT-TAB or RETURN key then make another text the first
|
||||
// responder. This depends on key.
|
||||
if (key_code == 0x09 || key_code == 0x0d) {
|
||||
if (key_code == 0x09 && (flags & NSShiftKeyMask))
|
||||
nextResponder = previous_text;
|
||||
else
|
||||
nextResponder = next_text;
|
||||
|
||||
if ([nextResponder respondsToSelector: @selector(selectText: )])
|
||||
// Either select the previous' text
|
||||
[nextResponder selectText: self];
|
||||
else
|
||||
// Or select ourself
|
||||
[self selectText: self];
|
||||
|
||||
// Have the target perform the action
|
||||
[self sendAction: [self action] to: [self target]];
|
||||
return;
|
||||
}
|
||||
|
||||
// If not editable then don't recognize the key down
|
||||
if (![self isEditable]) return;
|
||||
|
||||
|
||||
|
||||
NSDebugLLog(@"NSText", @"NSTextField: -keyDown %s\n",
|
||||
[[theEvent characters] cString]);
|
||||
|
||||
// If not editable then we ignore the key down, pass it on
|
||||
if (![self isEditable])
|
||||
{
|
||||
[super keyDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
// If the key is TAB (with or without SHIFT) or ESC, pass it on
|
||||
if ((key_code == 0x09) || (key_code == 0x1b))
|
||||
{
|
||||
[super keyDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
// We handle ENTER here, to avoid setting up an editing session
|
||||
// only for it.
|
||||
if (key_code == 0x0d)
|
||||
{
|
||||
[window selectKeyViewFollowingView: self];
|
||||
[self sendAction: [cell action] to: [cell target]];
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, start an editing session (FIXME the following)
|
||||
#if 1
|
||||
{
|
||||
NSRect cellFrame = bounds;
|
||||
|
@ -431,21 +405,6 @@ fprintf(stderr, " TextField mouseDown --- ");
|
|||
#endif
|
||||
}
|
||||
|
||||
- (void) keyUp: (NSEvent *)theEvent
|
||||
{
|
||||
unsigned int key_code = [theEvent keyCode];
|
||||
|
||||
// Ignore TAB and RETURN key
|
||||
if ((key_code == 0x09) || (key_code == 0x0d))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If not editable then don't recognize the key up
|
||||
if (![self isEditable])
|
||||
return;
|
||||
}
|
||||
|
||||
- (BOOL) acceptsFirstResponder
|
||||
{
|
||||
if ([self isSelectable] || [self isEditable])
|
||||
|
@ -533,8 +492,6 @@ fprintf(stderr, " TextField mouseDown --- ");
|
|||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeConditionalObject: next_text];
|
||||
[aCoder encodeConditionalObject: previous_text];
|
||||
[aCoder encodeConditionalObject: text_delegate];
|
||||
[aCoder encodeValueOfObjCType: @encode(SEL) at: &error_action];
|
||||
}
|
||||
|
@ -543,8 +500,6 @@ fprintf(stderr, " TextField mouseDown --- ");
|
|||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
next_text = [aDecoder decodeObject];
|
||||
previous_text = [aDecoder decodeObject];
|
||||
text_delegate = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &error_action];
|
||||
|
||||
|
|
|
@ -2131,35 +2131,6 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
{
|
||||
unsigned int key_code = [theEvent keyCode];
|
||||
|
||||
// If this is a TAB or TAB+SHIFT event, we handle it
|
||||
if (key_code == 0x09)
|
||||
{
|
||||
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
[window selectKeyViewPrecedingView: self];
|
||||
else
|
||||
[window selectKeyViewFollowingView: self];
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, let the event go on in the responder chain
|
||||
[super keyDown: theEvent];
|
||||
}
|
||||
|
||||
- (void) keyUp: (NSEvent *)theEvent
|
||||
{
|
||||
unsigned int key_code = [theEvent keyCode];
|
||||
|
||||
// We handle (ignoring them) TAB/SHIFT+TAB events
|
||||
if (key_code == 0x09)
|
||||
return;
|
||||
else // All other events go on in the chain
|
||||
[super keyUp: theEvent];
|
||||
}
|
||||
|
||||
/*
|
||||
* Dragging
|
||||
*/
|
||||
|
|
|
@ -1241,6 +1241,42 @@ static NSRecursiveLock *windowsLock;
|
|||
return _initial_first_responder;
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
{
|
||||
unsigned int key_code = [theEvent keyCode];
|
||||
|
||||
// TODO:
|
||||
// "A mnemonic matching the character(s) typed,
|
||||
// not requiring the Alternate key to be pressed"
|
||||
|
||||
// TODO:
|
||||
// "A key equivalent, not requiring the Command (or Control) key
|
||||
// to be pressed"
|
||||
|
||||
// If this is a TAB or TAB+SHIFT event, move to the next key view
|
||||
if (key_code == 0x09)
|
||||
{
|
||||
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
[self selectPreviousKeyView: self];
|
||||
else
|
||||
[self selectNextKeyView: self];
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is an ESC event, abort modal loop
|
||||
if (key_code == 0x1b)
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
if ([app isRunningModalForWindow: self])
|
||||
{
|
||||
// NB: The following *never* returns.
|
||||
[app abortModal];
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Otherwise, pass the event up
|
||||
[super keyDown: theEvent];
|
||||
}
|
||||
|
||||
/* Return mouse location in reciever's base coord system, ignores event
|
||||
* loop status */
|
||||
|
|
Loading…
Reference in a new issue