Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCN_MARGINRIGHTCLICK does not return margin #250

Closed
vinsworldcom opened this issue Nov 1, 2022 · 0 comments · Fixed by #251
Closed

SCN_MARGINRIGHTCLICK does not return margin #250

vinsworldcom opened this issue Nov 1, 2022 · 0 comments · Fixed by #251

Comments

@vinsworldcom
Copy link
Contributor

vinsworldcom commented Nov 1, 2022

According to Scintilla docs SCN_MARGINRIGHTCLICK should return the same arguments as SCN_MARGINCLICK - modifiers, position, margin. However, it does not. A simple example:

from Npp import editor, SCINTILLANOTIFICATION

class RCT(object):
    def __init__(self):
        editor.callbackSync(self._on_margin, 
            [SCINTILLANOTIFICATION.MARGINCLICK, 
            SCINTILLANOTIFICATION.MARGINRIGHTCLICK]
        )

    def _on_margin(self, args):
        print(args)

if __name__ == '__main__':
    rct = RCT()

Generates the following from a left-click (normal as expected) and then a right-click (lots of arguments, not the ones expected and no margin):

{'code': 2010, 'idFrom': 0, 'hwndFrom': 3870106, 'margin': 1, 'position': 544, 'modifiers': 0}
{'code': 2031, 'idFrom': 0, 'hwndFrom': 3870106, 'position': 544, 'modificationType': 0, 'length': 0, 'linesAdded': 0, 'line': 0, 'foldLevelNow': 0, 'foldLevelPrev': 0, 'annotationLinesAdded': 0, 'listType': 0, 'message': 0, 'wParam': 0, 'lParam': 0, 'modifiers': 0, 'token': 0, 'x': 0, 'y': 0}

There seems to be a case statement missing from 'PythonScript\src\ScintillaWrapper.cpp':

diff --git a/PythonScript/src/ScintillaWrapper.cpp b/PythonScript/src/ScintillaWrapper.cpp
index 2d1bd37..2707ecc 100644
--- a/PythonScript/src/ScintillaWrapper.cpp
+++ b/PythonScript/src/ScintillaWrapper.cpp
@@ -172,6 +172,12 @@ void ScintillaWrapper::notify(SCNotification *notifyCode)
                        case SCN_MARGINCLICK:
                                params["margin"] = notifyCode->margin;
                 params["position"] = notifyCode->position;
+                params["modifiers"] = notifyCode->modifiers;^M
+                               break;^M
+^M
+                       case SCN_MARGINRIGHTCLICK:^M
+                               params["margin"] = notifyCode->margin;^M
+                params["position"] = notifyCode->position;^M
                 params["modifiers"] = notifyCode->modifiers;
                                break;

That seems to be the fix - see PR #251

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant