Added performClickWithFrame:inView: to NSCell

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19005 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Quentin Mathe 2004-04-02 21:34:37 +00:00
parent 920a933a52
commit 28db48ddfd
9 changed files with 82 additions and 61 deletions

View file

@ -1,3 +1,24 @@
2004-04-02 Quentin Mathe <qmathe@club-internet.fr>
With the help of Fred Kiefer and Alexander Malmberg, the modifications
below are mainly introduced to fix the fact -[NSCell performClick:]
doesn't work correctly when the cell frame is not identical to the control
frame which is displaying it :
* Source/NSButton.m: Removed -performClick: method already present in
the superclass NSControl.
* Headers/AppKit/NSButton.h: Same.
* Source/NSButtonCell.m: Replaced -performClick: method by
-performClickWithFrame:inView: method which overrides new method with
the same name in the superclass NSCell.
* Headers/AppKit/NSButtonCell.h: Same
* Source/NSCell.m: Added a method -performClickWithFrame:inView:
to be used in place of -performClick: method which has been deprecated.
* Headers/AppKit/NSCell.h: Same
* Source/NSControl.m: Modified -performClick: method to use the new
NSCell method -performClickWithFrame:inView:.
* Source/NSPopUpButtonCell.m: Modified -performClickWithFrame:inView: to
override the new method with the same name in the superclass NSCell.
2004-04-02 Quentin Mathe <qmathe@club-internet.fr>
* Source/NSWindow+Toolbar.h: Moved into Headers/AppKit

View file

@ -122,7 +122,6 @@
//
// Handling Events and Action Messages
//
- (void)performClick:(id)sender;
- (BOOL)performKeyEquivalent:(NSEvent *)anEvent;
//

View file

@ -183,7 +183,6 @@ typedef enum _NSGradientType {
#ifndef STRICT_OPENSTEP
- (void)mouseEntered:(NSEvent *)event;
- (void)mouseExited:(NSEvent *)event;
- (void)performClick:(id)sender;
#endif
@end

View file

@ -333,7 +333,12 @@ typedef enum _NSControlSize {
- (unsigned int)mnemonicLocation;
- (BOOL)refusesFirstResponder;
- (void)setRefusesFirstResponder:(BOOL)flag;
// deprecated method now in favor of performClickWithFrame:inView:
- (void)performClick:(id)sender;
- (void)performClickWithFrame: (NSRect)cellFrame
inView: (NSView *)controlView;
#endif
//

View file

@ -387,11 +387,6 @@ static id buttonCellClass = nil;
// Handling Events and Action Messages
//
- (void) performClick: (id)sender
{
[_cell performClick: sender];
}
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
{
if ([self isEnabled])

View file

@ -1081,13 +1081,19 @@
[(NSView *)[event userData] setNeedsDisplay: YES];
}
- (void) performClick: (id)sender
/**
* Simulates a single mouse click on the button cell. This method overrides the
* cell method performClickWithFrame:inView: to add the possibility to play a sound
* associated with the click.
*/
- (void) performClickWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
if (_sound != nil)
{
[_sound play];
}
[super performClick: sender];
[super performClickWithFrame: cellFrame inView: controlView];
}
/*

View file

@ -1143,41 +1143,57 @@ static NSColor *shadowCol;
_cell.refuses_first_responder = flag;
}
/**
* Simulates a single click in the cell (only works with controls which have
* no more than one cell). This method is deprecated,
* performClickWithFrame:inView: is the right method to use now.
*/
- (void) performClick: (id)sender
{
SEL action = [self action];
NSView *cv = [self controlView];
if (cv != nil)
[self performClickWithFrame: [cv bounds] inView: cv];
}
/**
* Simulates a single click in the cell. The display of the cell with this event
* occurs in the area delimited by <var>cellFrame</var> within
* <var>controlView</var>.
*/
- (void) performClickWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
SEL action = [self action];
if(_cell.is_disabled == YES)
{
return;
}
if (cv != nil)
if (controlView != nil)
{
NSRect cvBounds = [cv bounds];
NSWindow *cvWin = [cv window];
NSWindow *cvWin = [controlView window];
[cv lockFocus];
[controlView lockFocus];
[self setNextState];
[self highlight: YES withFrame: cvBounds inView: cv];
[self highlight: YES withFrame: cellFrame inView: controlView];
[cvWin flushWindow];
// Wait approx 1/10 seconds
[[NSRunLoop currentRunLoop]
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
[self highlight: NO withFrame: cvBounds inView: cv];
[self highlight: NO withFrame: cellFrame inView: controlView];
[cvWin flushWindow];
[cv unlockFocus];
[controlView unlockFocus];
if (action)
{
NS_DURING
{
[(NSControl*)cv sendAction: action to: [self target]];
[(NSControl*)controlView sendAction: action to: [self target]];
}
NS_HANDLER
{

View file

@ -509,9 +509,15 @@ static Class actionCellClass;
/*
* Activation
*/
/**
* Simulates a single mouse click on the control. This method calls the cell's
* method performClickWithFrame:inView:. Take note that <var>sender</var> is not
* used.
*/
- (void) performClick: (id)sender
{
[_cell performClick: sender];
[_cell performClickWithFrame: [self bounds] inView: self];
}
- (BOOL)refusesFirstResponder

View file

@ -633,50 +633,24 @@ static NSImage *_pbc_image[2];
return NO;
}
// This method is called to simulate programmatically a click
// [as NSCell's performClick:]
// This method is not executed upon mouse down; rather, it should
// simulate what would happen upon mouse down. It should not start
// any real mouse tracking.
- (void) performClickWithFrame: (NSRect)frame
inView: (NSView *)controlView
// This method is called to simulate programmatically a click by overriding
// -[NSCell performClickWithFrame:inView:]
// This method is not executed upon mouse down; rather, it should simulate what
// would happen upon mouse down. It should not start any real mouse tracking.
/**
* Simulates a single click in the pop up button cell (the display of the cell
* with this event occurs in the area delimited by <var>frame</var> in the view
* <var>controlView</var>) and displays the popup button cell menu attached to
* the view <var>controlView</var>, the menu width depends on the
* <var>frame</var> width value.
*/
- (void) performClickWithFrame: (NSRect)frame inView: (NSView *)controlView
{
NSWindow *cvWin = [controlView window];
if(_cell.is_disabled == YES)
{
return;
}
[controlView lockFocus];
[self setNextState];
[self highlight: YES withFrame: frame inView: controlView];
[cvWin flushWindow];
// Wait approx 1/10 seconds
[[NSRunLoop currentRunLoop]
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
[self highlight: NO withFrame: frame inView: controlView];
[cvWin flushWindow];
[controlView unlockFocus];
[super performClickWithFrame: frame inView: controlView];
[self attachPopUpWithFrame: frame inView: controlView];
}
- (void) performClick: (id)sender
{
NSView *cv = [self controlView];
if (cv != nil)
{
[self performClickWithFrame: [cv bounds]
inView: cv];
}
}
// Arrow position for bezel style and borderless popups.
- (NSPopUpArrowPosition) arrowPosition
{