mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Source/NSWindow.m ([-sendEvent:], case NSRightMouseDown):
removed code to display the menu. This is now done by [NSView -rightMouseDown:]. Source/NSView.m: overrides -menu, changes -rightMouseDown: to display the menu, documents -menu, -menuForEvent: and +defaultMenu. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16413 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b2faf96893
commit
063710aa5f
3 changed files with 73 additions and 13 deletions
|
@ -1,3 +1,12 @@
|
|||
2003-04-10 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
|
||||
* Source/NSWindow.m ([-sendEvent:], case NSRightMouseDown):
|
||||
removed code to display the menu. This is now done by
|
||||
[NSView -rightMouseDown:].
|
||||
* Source/NSView.m: overrides -menu,
|
||||
changes -rightMouseDown: to display the menu,
|
||||
documents -menu, -menuForEvent: and +defaultMenu.
|
||||
|
||||
2003-04-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSServicesManager.m: on opening file, only activate for
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include <AppKit/NSClipView.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
#include <AppKit/NSPrintInfo.h>
|
||||
#include <AppKit/NSPrintOperation.h>
|
||||
|
@ -3764,14 +3765,58 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Menu operations
|
||||
/**
|
||||
* <p>Returns the default menu to be used for instances of the
|
||||
* current class: if no menu has been set through setMenu:
|
||||
* this default menu will be used.
|
||||
* </p>
|
||||
* <p>NSView's implementation returns nil. You should override
|
||||
* this method if you want all instances of your custom view
|
||||
* to use the same menu.
|
||||
* </p>
|
||||
*/
|
||||
+ (NSMenu *)defaultMenu
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>NSResponder's method, overriden by NSView.</p>
|
||||
* <p>If no menu has been set through the use of setMenu:, or
|
||||
* if a nil value has been set through setMenu:, then the
|
||||
* value returned by defaultMenu is used. Otherwise this
|
||||
* method returns the menu set through NSResponder.
|
||||
* <p>
|
||||
* <p> see [NSResponder -menu], [NSResponder -setMenu:],
|
||||
* [NSView +defaultMenu] and [NSView -menuForEvent:].
|
||||
* </p>
|
||||
*/
|
||||
- (NSMenu *)menu
|
||||
{
|
||||
NSMenu *m = [super menu];
|
||||
if (m)
|
||||
{
|
||||
return m;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [[self class] defaultMenu];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the menu that it appropriates for the given
|
||||
* event. NSView's implementation returns the default menu of
|
||||
* the view.</p>
|
||||
* <p>This methods is intended to be overriden so that it can
|
||||
* return a context-sensitive for appropriate mouse's events. (
|
||||
* (although it seems it can be used for any kind of event)</p>
|
||||
* <p>This method is used by NSView's rightMouseDown: method,
|
||||
* and the returned NSMenu is displayed as a context menu</p>
|
||||
* <p> see [NSResponder -menu], [NSResponder -setMenu:],
|
||||
* [NSView +defaultMenu] and [NSView -menu].
|
||||
* </p>
|
||||
*/
|
||||
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
|
||||
{
|
||||
return [self menu];
|
||||
|
@ -3938,5 +3983,21 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) rightMouseDown: (NSEvent *) theEvent
|
||||
{
|
||||
NSMenu *m;
|
||||
m = [self menuForEvent: theEvent];
|
||||
if (m)
|
||||
{
|
||||
[NSMenu popUpContextMenu: m
|
||||
withEvent: theEvent
|
||||
forView: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super rightMouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -2889,17 +2889,7 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
|
|||
{
|
||||
NSMenu *m;
|
||||
v = [_contentView hitTest: [theEvent locationInWindow]];
|
||||
m = [v menuForEvent: theEvent];
|
||||
if (m)
|
||||
{
|
||||
[NSMenu popUpContextMenu: m
|
||||
withEvent: theEvent
|
||||
forView: v];
|
||||
}
|
||||
else
|
||||
{
|
||||
[v rightMouseDown: theEvent];
|
||||
}
|
||||
[v rightMouseDown: theEvent];
|
||||
_lastPoint = [theEvent locationInWindow];
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue