mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 19:51:01 +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
954c6e0336
commit
228e7133be
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
|
* Source/NSWorkspace.m: Added private notification center class to
|
||||||
handle notifications to be passed between applications.
|
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>
|
Sat Oct 9 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Source/NSButton.m ([-keyDown:]): Perform a click if
|
* Source/NSButton.m ([-keyDown:]): Perform a click if
|
||||||
|
|
|
@ -118,6 +118,7 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
- (void) run;
|
- (void) run;
|
||||||
- (int) runModalForWindow: (NSWindow*)theWindow;
|
- (int) runModalForWindow: (NSWindow*)theWindow;
|
||||||
- (int) runModalSession: (NSModalSession)theSession;
|
- (int) runModalSession: (NSModalSession)theSession;
|
||||||
|
- (BOOL) isRunningModalForWindow: (NSWindow *)theWindow;
|
||||||
- (void) sendEvent: (NSEvent*)theEvent;
|
- (void) sendEvent: (NSEvent*)theEvent;
|
||||||
- (void) stop: (id)sender;
|
- (void) stop: (id)sender;
|
||||||
- (void) stopModal;
|
- (void) stopModal;
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
@interface NSTextField : NSControl <NSCoding>
|
@interface NSTextField : NSControl <NSCoding>
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
id next_text;
|
|
||||||
id previous_text;
|
|
||||||
id text_delegate;
|
id text_delegate;
|
||||||
SEL error_action;
|
SEL error_action;
|
||||||
NSCursor *text_cursor;
|
NSCursor *text_cursor;
|
||||||
|
|
|
@ -916,8 +916,6 @@ void __dummy_GMAppKit_functionForLinking() {}
|
||||||
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
|
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
|
||||||
[archiver encodeBOOL:[self isBordered] withName:@"isBordered"];
|
[archiver encodeBOOL:[self isBordered] withName:@"isBordered"];
|
||||||
[archiver encodeBOOL:[self isBezeled] withName:@"isBezeled"];
|
[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 encodeObject:[self delegate] withName:@"delegate"];
|
||||||
[archiver encodeString:[self stringValue] withName:@"stringValue"];
|
[archiver encodeString:[self stringValue] withName:@"stringValue"];
|
||||||
[archiver encodeBOOL:[self isEditable] withName:@"isEditable"];
|
[archiver encodeBOOL:[self isEditable] withName:@"isEditable"];
|
||||||
|
@ -940,8 +938,6 @@ void __dummy_GMAppKit_functionForLinking() {}
|
||||||
[self setBordered:[unarchiver decodeBOOLWithName:@"isBordered"]];
|
[self setBordered:[unarchiver decodeBOOLWithName:@"isBordered"]];
|
||||||
[self setBezeled:[unarchiver decodeBOOLWithName:@"isBezeled"]];
|
[self setBezeled:[unarchiver decodeBOOLWithName:@"isBezeled"]];
|
||||||
|
|
||||||
[self setNextText:[unarchiver decodeObjectWithName:@"nextText"]];
|
|
||||||
[self setPreviousText:[unarchiver decodeObjectWithName:@"previousText"]];
|
|
||||||
[self setDelegate:[unarchiver decodeObjectWithName:@"delegate"]];
|
[self setDelegate:[unarchiver decodeObjectWithName:@"delegate"]];
|
||||||
|
|
||||||
theCell = [self cell];
|
theCell = [self cell];
|
||||||
|
|
|
@ -446,10 +446,14 @@ NSApplication *NSApp = nil;
|
||||||
{
|
{
|
||||||
if (theSession)
|
if (theSession)
|
||||||
{
|
{
|
||||||
|
NSWindow *win_to_close = theSession->window;
|
||||||
|
|
||||||
[self endModalSession: theSession];
|
[self endModalSession: theSession];
|
||||||
|
[win_to_close close];
|
||||||
}
|
}
|
||||||
if ([[localException name] isEqual: NSAbortModalException] == NO)
|
if ([[localException name] isEqual: NSAbortModalException] == NO)
|
||||||
[localException raise];
|
[localException raise];
|
||||||
|
|
||||||
code = NSRunAbortedResponse;
|
code = NSRunAbortedResponse;
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
@ -550,6 +554,14 @@ NSApplication *NSApp = nil;
|
||||||
return theSession->runState;
|
return theSession->runState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isRunningModalForWindow: (NSWindow *)theWindow
|
||||||
|
{
|
||||||
|
if ((session) && (session->window == theWindow))
|
||||||
|
return YES;
|
||||||
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) stop: (id)sender
|
- (void) stop: (id)sender
|
||||||
{
|
{
|
||||||
if (session)
|
if (session)
|
||||||
|
|
|
@ -163,40 +163,22 @@ id _nsTextfieldCellClass = nil;
|
||||||
//
|
//
|
||||||
- (id) nextText
|
- (id) nextText
|
||||||
{
|
{
|
||||||
return next_text;
|
return _nextKeyView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) previousText
|
- (id) previousText
|
||||||
{
|
{
|
||||||
return previous_text;
|
return _previousKeyView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setNextText: (id)anObject
|
- (void) setNextText: (id)anObject
|
||||||
{
|
{
|
||||||
id t;
|
[self setNextKeyView: anObject];
|
||||||
|
|
||||||
// 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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setPreviousText: (id)anObject
|
- (void) setPreviousText: (id)anObject
|
||||||
{
|
{
|
||||||
id t;
|
[self setPreviousKeyView: anObject];
|
||||||
|
|
||||||
// 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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -352,47 +334,39 @@ fprintf(stderr, " TextField mouseDown --- ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// This is called if a key is pressed when an editing session
|
||||||
* Get characters until you encounter
|
// is not yet started. (If needed, we start it from here).
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
- (void) keyDown: (NSEvent *)theEvent
|
- (void) keyDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
unsigned int flags = [theEvent modifierFlags];
|
|
||||||
unsigned int key_code = [theEvent keyCode];
|
unsigned int key_code = [theEvent keyCode];
|
||||||
id nextResponder;
|
|
||||||
|
|
||||||
NSDebugLLog(@"NSText",
|
NSDebugLLog(@"NSText", @"NSTextField: -keyDown %s\n",
|
||||||
@"NSTextField: -keyDown %s\n", [[theEvent characters] cString]);
|
[[theEvent characters] cString]);
|
||||||
|
|
||||||
// If TAB, SHIFT-TAB or RETURN key then make another text the first
|
// If not editable then we ignore the key down, pass it on
|
||||||
// responder. This depends on key.
|
if (![self isEditable])
|
||||||
if (key_code == 0x09 || key_code == 0x0d) {
|
{
|
||||||
if (key_code == 0x09 && (flags & NSShiftKeyMask))
|
[super keyDown: theEvent];
|
||||||
nextResponder = previous_text;
|
return;
|
||||||
else
|
}
|
||||||
nextResponder = next_text;
|
|
||||||
|
|
||||||
if ([nextResponder respondsToSelector: @selector(selectText: )])
|
// If the key is TAB (with or without SHIFT) or ESC, pass it on
|
||||||
// Either select the previous' text
|
if ((key_code == 0x09) || (key_code == 0x1b))
|
||||||
[nextResponder selectText: self];
|
{
|
||||||
else
|
[super keyDown: theEvent];
|
||||||
// Or select ourself
|
return;
|
||||||
[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;
|
|
||||||
|
|
||||||
|
// 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
|
#if 1
|
||||||
{
|
{
|
||||||
NSRect cellFrame = bounds;
|
NSRect cellFrame = bounds;
|
||||||
|
@ -431,21 +405,6 @@ fprintf(stderr, " TextField mouseDown --- ");
|
||||||
#endif
|
#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
|
- (BOOL) acceptsFirstResponder
|
||||||
{
|
{
|
||||||
if ([self isSelectable] || [self isEditable])
|
if ([self isSelectable] || [self isEditable])
|
||||||
|
@ -533,8 +492,6 @@ fprintf(stderr, " TextField mouseDown --- ");
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
[aCoder encodeConditionalObject: next_text];
|
|
||||||
[aCoder encodeConditionalObject: previous_text];
|
|
||||||
[aCoder encodeConditionalObject: text_delegate];
|
[aCoder encodeConditionalObject: text_delegate];
|
||||||
[aCoder encodeValueOfObjCType: @encode(SEL) at: &error_action];
|
[aCoder encodeValueOfObjCType: @encode(SEL) at: &error_action];
|
||||||
}
|
}
|
||||||
|
@ -543,8 +500,6 @@ fprintf(stderr, " TextField mouseDown --- ");
|
||||||
{
|
{
|
||||||
[super initWithCoder: aDecoder];
|
[super initWithCoder: aDecoder];
|
||||||
|
|
||||||
next_text = [aDecoder decodeObject];
|
|
||||||
previous_text = [aDecoder decodeObject];
|
|
||||||
text_delegate = [aDecoder decodeObject];
|
text_delegate = [aDecoder decodeObject];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &error_action];
|
[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
|
* Dragging
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1241,6 +1241,42 @@ static NSRecursiveLock *windowsLock;
|
||||||
return _initial_first_responder;
|
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
|
/* Return mouse location in reciever's base coord system, ignores event
|
||||||
* loop status */
|
* loop status */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue