mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 23:30:46 +00:00
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:
parent
920a933a52
commit
28db48ddfd
9 changed files with 82 additions and 61 deletions
21
ChangeLog
21
ChangeLog
|
@ -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>
|
2004-04-02 Quentin Mathe <qmathe@club-internet.fr>
|
||||||
|
|
||||||
* Source/NSWindow+Toolbar.h: Moved into Headers/AppKit
|
* Source/NSWindow+Toolbar.h: Moved into Headers/AppKit
|
||||||
|
|
|
@ -122,7 +122,6 @@
|
||||||
//
|
//
|
||||||
// Handling Events and Action Messages
|
// Handling Events and Action Messages
|
||||||
//
|
//
|
||||||
- (void)performClick:(id)sender;
|
|
||||||
- (BOOL)performKeyEquivalent:(NSEvent *)anEvent;
|
- (BOOL)performKeyEquivalent:(NSEvent *)anEvent;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -183,7 +183,6 @@ typedef enum _NSGradientType {
|
||||||
#ifndef STRICT_OPENSTEP
|
#ifndef STRICT_OPENSTEP
|
||||||
- (void)mouseEntered:(NSEvent *)event;
|
- (void)mouseEntered:(NSEvent *)event;
|
||||||
- (void)mouseExited:(NSEvent *)event;
|
- (void)mouseExited:(NSEvent *)event;
|
||||||
- (void)performClick:(id)sender;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -333,7 +333,12 @@ typedef enum _NSControlSize {
|
||||||
- (unsigned int)mnemonicLocation;
|
- (unsigned int)mnemonicLocation;
|
||||||
- (BOOL)refusesFirstResponder;
|
- (BOOL)refusesFirstResponder;
|
||||||
- (void)setRefusesFirstResponder:(BOOL)flag;
|
- (void)setRefusesFirstResponder:(BOOL)flag;
|
||||||
- (void)performClick:(id)sender;
|
|
||||||
|
// deprecated method now in favor of performClickWithFrame:inView:
|
||||||
|
- (void)performClick:(id)sender;
|
||||||
|
|
||||||
|
- (void)performClickWithFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView *)controlView;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -387,11 +387,6 @@ static id buttonCellClass = nil;
|
||||||
// Handling Events and Action Messages
|
// Handling Events and Action Messages
|
||||||
//
|
//
|
||||||
|
|
||||||
- (void) performClick: (id)sender
|
|
||||||
{
|
|
||||||
[_cell performClick: sender];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
|
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
|
||||||
{
|
{
|
||||||
if ([self isEnabled])
|
if ([self isEnabled])
|
||||||
|
|
|
@ -1081,13 +1081,19 @@
|
||||||
[(NSView *)[event userData] setNeedsDisplay: YES];
|
[(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)
|
if (_sound != nil)
|
||||||
{
|
{
|
||||||
[_sound play];
|
[_sound play];
|
||||||
}
|
}
|
||||||
[super performClick: sender];
|
|
||||||
|
[super performClickWithFrame: cellFrame inView: controlView];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1143,41 +1143,57 @@ static NSColor *shadowCol;
|
||||||
_cell.refuses_first_responder = flag;
|
_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
|
- (void) performClick: (id)sender
|
||||||
{
|
{
|
||||||
SEL action = [self action];
|
|
||||||
NSView *cv = [self controlView];
|
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)
|
if(_cell.is_disabled == YES)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cv != nil)
|
if (controlView != nil)
|
||||||
{
|
{
|
||||||
NSRect cvBounds = [cv bounds];
|
NSWindow *cvWin = [controlView window];
|
||||||
NSWindow *cvWin = [cv window];
|
|
||||||
|
|
||||||
[cv lockFocus];
|
[controlView lockFocus];
|
||||||
|
|
||||||
[self setNextState];
|
[self setNextState];
|
||||||
[self highlight: YES withFrame: cvBounds inView: cv];
|
[self highlight: YES withFrame: cellFrame inView: controlView];
|
||||||
[cvWin flushWindow];
|
[cvWin flushWindow];
|
||||||
|
|
||||||
// Wait approx 1/10 seconds
|
// Wait approx 1/10 seconds
|
||||||
[[NSRunLoop currentRunLoop]
|
[[NSRunLoop currentRunLoop]
|
||||||
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
|
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
|
||||||
|
|
||||||
[self highlight: NO withFrame: cvBounds inView: cv];
|
[self highlight: NO withFrame: cellFrame inView: controlView];
|
||||||
[cvWin flushWindow];
|
[cvWin flushWindow];
|
||||||
|
|
||||||
[cv unlockFocus];
|
[controlView unlockFocus];
|
||||||
|
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
[(NSControl*)cv sendAction: action to: [self target]];
|
[(NSControl*)controlView sendAction: action to: [self target]];
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
|
|
@ -509,9 +509,15 @@ static Class actionCellClass;
|
||||||
/*
|
/*
|
||||||
* Activation
|
* 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
|
- (void) performClick: (id)sender
|
||||||
{
|
{
|
||||||
[_cell performClick: sender];
|
[_cell performClickWithFrame: [self bounds] inView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)refusesFirstResponder
|
- (BOOL)refusesFirstResponder
|
||||||
|
|
|
@ -633,50 +633,24 @@ static NSImage *_pbc_image[2];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method is called to simulate programmatically a click
|
// This method is called to simulate programmatically a click by overriding
|
||||||
// [as NSCell's performClick:]
|
// -[NSCell performClickWithFrame:inView:]
|
||||||
// This method is not executed upon mouse down; rather, it should
|
// This method is not executed upon mouse down; rather, it should simulate what
|
||||||
// simulate what would happen upon mouse down. It should not start
|
// would happen upon mouse down. It should not start any real mouse tracking.
|
||||||
// any real mouse tracking.
|
/**
|
||||||
- (void) performClickWithFrame: (NSRect)frame
|
* Simulates a single click in the pop up button cell (the display of the cell
|
||||||
inView: (NSView *)controlView
|
* 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
|
||||||
NSWindow *cvWin = [controlView window];
|
* the view <var>controlView</var>, the menu width depends on the
|
||||||
|
* <var>frame</var> width value.
|
||||||
if(_cell.is_disabled == YES)
|
*/
|
||||||
{
|
- (void) performClickWithFrame: (NSRect)frame inView: (NSView *)controlView
|
||||||
return;
|
{
|
||||||
}
|
[super performClickWithFrame: frame inView: controlView];
|
||||||
|
|
||||||
[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];
|
|
||||||
|
|
||||||
[self attachPopUpWithFrame: 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.
|
// Arrow position for bezel style and borderless popups.
|
||||||
- (NSPopUpArrowPosition) arrowPosition
|
- (NSPopUpArrowPosition) arrowPosition
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue