key callback not registering

  • prozaker

    prozaker - 2010-11-18

    Hello I'm trying to register a call back but neither of these ways work:

    def keypressed(args):
    notepad.callback(keypressed, [SCINTILLANOTIFICATION.KEY])
    editor.callback(keypressed, [SCINTILLANOTIFICATION.KEY])

    Thanks in advance

  • Dave Brotherstone

    The one you mean is

    editor.callback(keypressed, [SCINTILLANOTIFICATION.KEY])

    notepad.callback uses the NOTIFICATION enum, not the SCINTILLANOTIFICATION.  But, I expect that's not the notification you wanted - according to the scintilla documentation - (

    Reports all keys pressed but not consumed by Scintilla. Used on GTK+ because of some problems with keyboard focus and is not sent by the Windows version. holds the key code and SCNotification.modifiers holds the modifiers. This notification is sent if the modifiers include SCMOD_ALT or SCMOD_CTRL and the key code is less than 256.

    So, you'll only get keys that don't have any effect in Scintilla…  I'm assuming that's not what you wanted?

    Take a look at SCINTILLANOTIFICATION.CHARADDED  (SCN_CHARADDED in the Scintilla documentation).   Of course without knowing what you're trying to achieve, it's difficult to say :)

    Be aware that clearing events is unstable when called from within an event handler in 0.7.  This is fixed in 0.8.


  • prozaker

    prozaker - 2010-11-18

    Hi Dave, well let me give you an insight of what I i'm trying to do.

    I have a py file that holds 2 clases, one for filepositions and filepositioncollection

    fileposition collection gets the line # of the bufferid and stores that as a fileposition object, everytime a new line is modified it saves the line #.

    what i want to do (which happens in eclipse, and used to happen in npp with changemarkers) is to jump through the lines i've have modified.

    since change markers is unstable in current npp…

    maybe i should do a script for forward and backward keys, and then set those up as shortcuts, i was thinking of alt+up and alt+down?

  • Dave Brotherstone

    Yes, the best way to do this is to create two new scripts, and assign them shortcuts.

    Incidentally, Change Markers is only "unstable" if you use Save-All, or "replace in all open documents".


  • arntof

    arntof - 2010-11-20

    I tried this
    def do_sth(args):
        console.write("args: " + str(args))
    notepad.callback(do_sth, [SCINTILLANOTIFICATION.CHARADDED])

    but as I am typing nothing happens.
    I'm a brand new n++ python script user - am I overlooking something here?

    thanks in advance.

  • Dave Brotherstone

    You need to use

    editor.callback(do_sth, [SCINTILLANOTIFICATION.CHARADDED])

    editor is the Scintilla object, so anything to do with the text area is normally the editor object.  Notepad object is for things like opening and saving files, running menu options and so on.  The notepad.callback function also uses the NOTIFICATION enum, not the SCINTILLANOTIFICATION enum.


  • arntof

    arntof - 2010-11-20



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks