scintilla1_charAdded not called

Topics: User Forum
Mar 10, 2015 at 5:43 PM
I am trying to get autocomplete working, after looking through the discussions I ended up with this code. However my scintilla1_CharAdded listener is never triggered. I'm not sure why. I tested by putting breakpoints in the code to be sure. And that code is never entered. Do I have to assign the listener to the object like in Java? Rexx is my custom lexer by the way, not sure if that is interfering somehow. Thanks.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ScintillaNET;

namespace OPS_IDE
{
public partial class Form1 : Form
{
    private const string keywords = "ADDRESS ARG CALL DO DROP EXIT IF INTERPRET ITERATE LEAVE NOP NUMERIC OPTIONS PARSE PROCEDURE PULL PUSH QUEUE RETURN SAY SELECT SIGNAL TRACE";
    List<string> keywordList;
    public Form1()
    {
        InitializeComponent();
        scintilla1.Margins[0].Width = 20;
        scintilla1.ConfigurationManager.Language = "rexx";
        scintilla1.Lexing.Keywords[0] = keywords;
        scintilla1.AutoComplete.DropRestOfWord = true;
        scintilla1.AutoComplete.AutoHide = false;
        keywordList = new List<string>(keywords.Split(' '));
        keywordList.Sort(); 
    }
    private void scintilla1_CharAdded(object sender, CharAddedEventArgs e)
    {
        if (e.Ch == ' ')
            return;
        int pos = scintilla1.NativeInterface.GetCurrentPos();
        string word = scintilla1.GetWordFromPosition(pos);
        if (word == string.Empty)
            return;
        List<string> list = keywordList.FindAll(item => item.StartsWith(word));
        if (list.Count > 0)
            scintilla1.AutoComplete.Show(list);
    }
}
}
Mar 12, 2015 at 2:37 PM
I added this line under Initialize Component and it works now.

scintilla1.CharAdded += scintilla1_CharAdded;