Kit Yam Tse:
> <patch.diff>
The patch applied correctly although there is a problem with ScintillaWin.cxx (discussed in last paragraph).
The <Event> methods came before the <Event>WithModifiers methods and only exist for compatibility with old platform layers. Since right click is new, there only needs to be RightButtonDownWithModifiers and no RightButtonDown. Passing a bitmask allows adding more flags in the future whereas the 3 explicit bools doesn’t.
For Qt, the raw flags should be reported. The weird rectangular case is just for dragging rectangular selections because Alt+Drag is often intercepted by X11 window managers. So drop the Q_WS_X11 segment.
Copy the indentation and brace positioning style of the file - most of Scintilla is 1TBS with tabs. Some of the platform layers were contributed by others and should follow their current style.
Editor::GetMargin and Editor::RightMarginClick don’t look similar to other methods in Editor. If GetMargin is const (as it appears to be) it should be marked const. Since it looks like it only accesses ‘vs’ it may be possible to move it onto ViewStyle. Editor is too big and code should be moved out where it is sensible.
The empty braces after WM_RBUTTONDOWN aren’t correct and this file doesn’t build: there should just be an opening brace.
The debug trace shouldn’t be included (and I should remove some of the others left in the file).
Neil
The argument to ShouldDisplayPopup isn’t in window coordinates as it is negative when over the margin on Cocoa. On Cocoa, it can be thought of as relative to the text view. On most other platforms it is relative to the combined margin & text view.
The check for implementation appears to have no effect in the current code or this patch. ShouldDisplayPopupOnText and ShouldDisplayPopupOnMargin are never called for me. Perhaps because NSView has an empty implementation of menuForEvent:.
- (NSMenu*) menuForEvent: (NSEvent*) theEvent
{
if ([mOwner methodForSelector:@selector(menuForEvent:)] != [[ScintillaView class] instanceMethodForSelector:@selector(menuForEvent:)]) {
// menuForEvent Overriden
return [mOwner menuForEvent: theEvent];
} else if (mOwner.backend->ShouldDisplayPopupOnText()) {
return mOwner.backend->CreateContextMenu(theEvent);
} else {
return nil;
}
}
```
And here is the code:```- (NSMenu*) menuForEvent: (NSEvent*) theEvent{if ([mOwner methodForSelector:@selector(menuForEvent:)] != [[ScintillaView class] instanceMethodForSelector:@selector(menuForEvent:)]) {// menuForEvent Overridenreturn [mOwner menuForEvent: theEvent];} else if (mOwner.backend->ShouldDisplayPopupOnText()) {return mOwner.backend->CreateContextMenu(theEvent);} else {return nil;}}```By the way, ShouldDisplayPopupOnText , should be true here by default on Cocoa at my patch. If we don't want to have the menu by default in Cocoa, then we can set `SCI_USEPOPUP` to `SC_POPUP_NEVER` when we init ScintillaView.