using showHint for multiple lists


#1

I would like to use showHint with multiple lists associated with different CTR-key. That is, CTRL-A to bring up list A and CTRL-B to bring up list B. Is this possible?

Looking at the “synonym” showHint example, I thought maybe I can detect what keys were pressed and switch the “comp” to point to different completion list. But I am unable to figure out a way to detect the keys pressed.

Does anyone know a way to accomplish this?

Thanks.


#2

Yes. You can pass showHint a completion function to use, and bind different keys to different invocations of showHint.


#3

Thanks, Marijn. How would I pass the “completion” function to showHint()? I tried cm.showHint(function () {…}) but the function didn’t get called. Could you give an example?


#4

See the documentation, specifically the hint option.