aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa/ScintillaView.mm
diff options
context:
space:
mode:
authorTse Kit Yam <me@kytse.com>2016-11-23 10:46:28 +1100
committerTse Kit Yam <me@kytse.com>2016-11-23 10:46:28 +1100
commitd2c7abab397926735f5a41ca17fd280a409e2940 (patch)
treeefe207d319eef0ac417295439593a7baf36e20c7 /cocoa/ScintillaView.mm
parent4ae76e455aec66826a284356d63cc2b5995c0b2f (diff)
downloadscintilla-mirror-d2c7abab397926735f5a41ca17fd280a409e2940.tar.gz
Implementation of MarginRightClick event.
Diffstat (limited to 'cocoa/ScintillaView.mm')
-rw-r--r--cocoa/ScintillaView.mm32
1 files changed, 29 insertions, 3 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index 7000d96e3..ab0c4375b 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -116,6 +116,21 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)
}
}
+/**
+ * Called by the framework if it wants to show a context menu for the margin.
+ */
+- (NSMenu*) menuForEvent: (NSEvent*) theEvent
+{
+ NSMenu *menu = [owner menuForEvent: theEvent];
+ if (menu) {
+ return menu;
+ } else if (owner.backend->ShouldDisplayPopupOnMargin()) {
+ return owner.backend->CreateContextMenu(theEvent);
+ } else {
+ return nil;
+ }
+}
+
- (void) mouseDown: (NSEvent *) theEvent
{
NSClipView *textView = [[self scrollView] contentView];
@@ -123,6 +138,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)
owner.backend->MouseDown(theEvent);
}
+- (void) rightMouseDown: (NSEvent *) theEvent
+{
+ [NSMenu popUpContextMenu:[self menuForEvent: theEvent] withEvent:theEvent forView:self];
+
+ owner.backend->RightMouseDown(theEvent);
+}
+
- (void) mouseDragged: (NSEvent *) theEvent
{
owner.backend->MouseMove(theEvent);
@@ -380,10 +402,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)
*/
- (NSMenu*) menuForEvent: (NSEvent*) theEvent
{
- if (![mOwner respondsToSelector: @selector(menuForEvent:)])
+ NSMenu *menu = [mOwner menuForEvent: theEvent];
+ if (menu) {
+ return menu;
+ } else if (mOwner.backend->ShouldDisplayPopupOnText()) {
return mOwner.backend->CreateContextMenu(theEvent);
- else
- return [mOwner menuForEvent: theEvent];
+ } else {
+ return nil;
+ }
}
//--------------------------------------------------------------------------------------------------