This space is available to any ComponentArt employee to write about anything.

Browse by Tags

All Tags » SpellCheck » Web.UI   (RSS)

  • 2
    Comments
    1199 Views

    SpellCheck Client-side API

    The SpellCheck control, like most others in Web.UI, includes a powerful client-side API. The philosophy behind SpellCheck’s design is that as little as possible should be baked right into the control when it comes to visual interface, and that custom user experiences should be made as easy as possible via a powerful and versatile client-side API. Below are some examples. To check some text and see how many errors there are, we can do the following: var text = "This is some text with spleling misteaks in it." function spellComplete(result) { alert('SpellCheck complete: ' + Spell1.get_numErrors() + ' errors found.'); } Spell1.Check(text, spellComplete); Continuing from the above example, this is how we can go through the errors and see what they are: for(var i = 0; i < Spell1.get_numErrors(); i++) { alert('Error number ' + i + ' is: ' + Spell1.getError(i)); } We can expand the loop above to show the user what some alternatives might be for each of those errors: var currentError; function suggestHandler(result) { alert('You typed\'' + currentError + '\' but maybe you meant to type one of these: ' + result); } for(var i = 0; i < Spell1.get_numErrors(); i++) { currentError = Spell1.getError(i); Spell1.getSuggestions(currentError, suggestHandler); } We can also use the client-side API to change errors in the text right where they appear. For instance, we could alter the above to simply replace every misspelled word with the first suggestion returned by SpellCheck: var currentErrorIndex; function suggestHandler(result) { text = Spell1.Change(text, null, currentErrorIndex, result[0]); } for(var i = 0; i < Spell1.get_numErrors(); i++) { currentErrorIndex = i; Spell1.getSuggestions(currentError, suggestHandler); } In the above example, we’ve been passing around the text variable, which we defined ourselves. When SpellCheck’s ControlToCheck property is set, null can be passed instead of text to any method that requires it – the control will get the relevant text itself, and interventions will be made right on the text in question, whether it’s in a form field or any other DOM element. We hope you find this useful. Let us know what you think. Share this post: email it! | bookmark it! | digg it! | reddit!

    Posted by: Milos
    Posted: Wednesday, November 07, 2007 10:55 AM
    Filed under: , , ,
    2 Comments



  • Introducing SpellCheck

    Version 2007.2 of Web.UI brings with it two new controls: Editor and SpellCheck. In this post, I will provide a brief overview of SpellCheck, describing its abilities and the design philosophy behind it. SpellCheck, as its name suggests, is an ASP.NET control used for facilitating spellchecking on a web page. SpellCheck can be used to check the spelling of any textual content on a page, whether in an input field, text area, or any other element. It uses AJAX techniques to communicate efficiently with its server-side logic, and exposes a rich and versatile client-side API for controlling the checking process. Dialog-based Checking The most common way that people interface with spelling checkers is via a pop-up dialog. The dialog guides the user through the checking process, going through the errors in order and bringing up suggestions for each. When the process is done, the dialog closes. For an example of this UI, check out our dialog-based SpellCheck demo . SpellCheck’s client-side API includes an array of methods and events which were designed to facilitate such interaction, while imposing absolutely no restrictions on the nature of the dialog or its layout or styling. Methods like dialogBegin, dialogChange and dialogIgnoreAll were designed to be invoked by buttons commonly found on spellchecking dialogs. Generic methods like getSuggestions are also used to move the process along. In our own example, we use this API to interface with SpellCheck using our own Dialog control. However, the same can be accomplished using any control or mechanism which invokes the dialog-related public methods. In-place Highlighting with Context Menus When the target being checked is a DOM element other than a form-field, checking can be done using in-place highlighting. This means that SpellCheck will actually intervene in the markup being targeted and highlight the words that are spelled incorrectly. When the user clicks on such a word, a context menu is displayed, offering a list of suggested words to replace the mistake. Since the context menu (a ComponentArt Menu, naturally) is populated on the client as needed, it can be styled in any way in its server-side definition, and simply pointed to using SpellCheck’s ContextMenuId property. This mechanism is often seen as more convenient than a dialog-based one, and requires no external code to put together. You can see an example of this UI in our context-based SpellCheck demo . Client-side API The above examples are only the most common ways the spell checking process is organized. Since SpellCheck exposes all the key components of the process via its client-side API, it should support any novel interface that is envisioned. With methods like check, getSuggestions, change, ignore and addToDictionary, there are very few limitations to the kind of experience that can be designed around them. Up next: more on SpellCheck's client-side API. Stay tuned. Share this post: email it! | bookmark it! | digg it! | reddit!

    Posted by: Milos
    Posted: Tuesday, November 06, 2007 6:36 AM
    Filed under: , ,
    0 Comments




Blogs On This Site
Thoughts on web user interfaces and component development.
Ramblings of a web control developer.
Web.UI news and more
Next weeks guest: A dog and a baby dog!
I'm in your base, killing your dudes.
Absurdity is it's own message.
Musings of an ex Java developer
im in ur page, hackin ur codez
ComponentArt in the Community
... and the program ran happily ever after.

This Blog