Listen for a spell check event

  1. Import the following classes:
    • java.lang.StringBuffer
    • net.rim.device.api.ui.UiApplication
    • net.rim.device.api.ui.Field
  2. Import the following interfaces:
    • net.rim.blackberry.api.spellcheck.SpellCheckUIListener
    • net.rim.blackberry.api.spellcheck.SpellCheckEngine
  3. Create a method that returns the SpellCheckUIListener.LEARNING_ACCEPT constant when the SpellCheckEngine learns a new word.
    public int wordLearned(SpellCheckUI ui, StringBuffer word) {
       UiApplication.getUiApplication().invokeLater(new popUpRunner("Word learned")); 
       return SpellCheckUIListener.LEARNING_ACCEPT;
    }
  4. Create a method that returns the SpellCheckUIListener.LEARNING_ACCEPT constant when the SpellCheckEngine learns a correction for a word.
    public int wordCorrectionLearned(SpellCheckUI ui, StringBuffer word, StringBuffer correction){ 
       UiApplication.getUiApplication().invokeLater(new popUpRunner("Correction learned"));         
       return SpellCheckUIListener.LEARNING_ACCEPT;
    } 
  5. Create a method that returns the SpellCheckUIListener.ACTION_OPEN_UI constant when the SpellCheckEngine finds a misspelled word.
    public int misspelledWordFound(SpellCheckUI ui, Field field, int offset, int len){
       UiApplication.getUiApplication().invokeLater(new popUpRunner("Misspelled word found")); 
       return SpellCheckUIListener.ACTION_OPEN_UI;       
    } 
Next topic: Barcode scanning

Was this information helpful? Send us your comments.