Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding IntelliSense/AutoComplete in JavaScript
    primarykey
    data
    text
    <p>I currently maintain an add-on for Firefox that adds a number of capabilities to a forum web site that implements its own markup language, similar to what stackoverflow provides with "Markdown."</p> <p>I have built an IntelliSense function for this add-on, which, similar to Visual Studio, will pop up an auto-suggest when typing this markup in a textarea. Example:</p> <p><a href="http://members.lycos.co.uk/suffusion/namfox/faq-1.5/autocomplete-example-2-1.jpg" rel="noreferrer">http://members.lycos.co.uk/suffusion/namfox/faq-1.5/autocomplete-example-2-1.jpg</a></p> <p>The hardest thing about the implementation is finding the (x,y) coordinates of a key press in a textarea so I can pop-up the IntelliSense window very close to it. The keypress events in JavaScript do not expose these coordinates, so I've had to work around this. Unfortunately I could only find a cross-browser compatible way of getting the y-coordinate, not the x-coordinate. The code for this is located <a href="http://code.google.com/p/namfox/source/browse/trunk/chrome/content/enhancements/auto-complete/AutoCompleteController.js#281" rel="noreferrer">here</a> in the _getPopupPoint function.</p> <p>This works for Firefox because I use some of Mozilla's XPCOM interfaces to get the coordinate. So while this works for Firefox, now that I want to port my add-on to Google Chrome, I couldn't find a way to get the coordinates.</p> <p>So what I'm asking is twofold: (1) Is there a better way to get the x-coordinate of a key press? (2) If not, is there anything I can do in the context of a Google Chrome add-on to get the same data?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload