mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 00:50:38 +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
|
@ -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])
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
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];
|
||||
|
||||
// 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
|
||||
{
|
||||
[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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue