This project is read-only.

Fixes for Event handling

Topics: Developer Forum
Sep 12, 2006 at 3:52 PM

Some time ago, I sent event handling bugfixes on the scintillanet mailing list. As they have not yet been integrated in the current code base, and for completeness, I repost the fixes here. Basically, the problem is that events are not raised as expected because the enum-based event handlers lookup in Events[] collection just doesn't work.

The other problem is that CharAddedEventArgs didn't store the character correctly.

The diff's against version 5315 are the following:

--- Scintilla.cs 2006-09-12 06:58:36.000000000 +0200
+++ ScintillaNET-5315/ScintillaNET/ScintillaNET/ScintillaBindingGenerator/Scintilla.cs 2006-09-12 16:19:53.004065200 +0200
@@ -745,17 +745,18 @@
name = "SCKey";

string text = string.Format(
-@" public event EventHandler<{0}EventArgs> {0}
+@" private static readonly object {0}Event = new object();
+ public event EventHandler<{0}EventArgs> {0}
- add {{ Events.AddHandler(Scintilla.Enums.Events.{0}, value); }}- remove Events.RemoveHandler(Scintilla.Enums.Events.{0}, value);
+ add Events.AddHandler({0}Event, value);
+ remove Events.RemoveHandler({0}Event, value);
}} ", name);

membertext +=string.Format(
@" case Scintilla.Enums.Events.{0}:
- if (EventsScintilla.Enums.Events.{0} != null)
- ((EventHandler<{0}EventArgs>)EventsScintilla.Enums.Events.{0})(this, new {0}EventArgs(notification));
+ if (Events{0}Event != null)
+ ((EventHandler<{0}EventArgs>)Events{0}Event)(this, new {0}EventArgs(notification));


--- EventArgs.cs 2006-09-12 06:58:36.000000000 +0200
+++ ScintillaNET-5315/ScintillaNET/ScintillaNET/ScintillaNET/EventArgs.cs 2006-09-12 16:28:51.266815600 +0200
@@ -25,6 +25,7 @@
internal CharAddedEventArgs(SCNotification eventSource)
+ _ch =;

Sep 12, 2006 at 5:21 PM
This discussion has been copied to Work Item 3147. You may wish to continue further discussion there.
Sep 12, 2006 at 10:55 PM
Oh, I appologise.

I've integrated that into my tree, I'll sync up and commit my changes when I get back to Seattle on Friday.

I'll probably release alpha 2 this weekend, which should have all the latest fixes, but not styling.

Jan 27, 2007 at 10:19 PM
There seems to be an error trying to access that workitem 3147, and I see I'm not the first to experience it either.

The question I had I would have checked in there on was is there implementations for the other EventArgs somewhere that someone is working on? For instance MarginClickEventArgs is missing the rather handy properties like Position and Margin... ;-)

I'm just hacking the source as required to get running at the moment but obviously would rather be working with the official code rather than re-merging every time I re-download...

Thanks all for the efforts btw.
Jan 28, 2007 at 1:09 AM
OK I added the event arg implementation for MarginClick. Also I submitted the WorkItem error to CodePlex.

Also do you have any more event args you want put in? I know that I really should go through ALL of them but I'm focusing on other things right now so I'm just putting in the ones people actively need :)
Jan 28, 2007 at 2:37 AM
Great turnaround thanks mate, I shall grab it on my next "cycle". That was the event that jumped out at me for now in my very basic prototype but if I find some more I shall let you know ;-)

Right now my biggest issue is with Scintilla itself. Only having one bit left (ie. for one indicator) for the html parser which displays xml documents is a pita if you actually want to use two indicators...

I'm hacking the source of that to see if I can knock up a lightweight xml lexer since that needs only the basic dozen or so styles for the sorts of documents I intend processing - it could all end in tears very shortly... ;-)