Interface TextControl

 

Description

In BBj 7.0 and higher, all text-based BBjControls implement the TextControl interface. When spell checking is enabled, the text control monitors the user's typing, underlines misspelled words, and adds a popup menu with options to correct spelling mistakes.

Implementing Classes

BBjCEdit, BBjEditBox, BBjEditBoxSpinner, BBjInputD, BBjInputDSpinner, BBjInputE, BBjInputESpinner, BBjInputN, BBjInputNSpinner, BBjListEdit

Methods of TextControl

Return Value

Method

void

addWord(string word)

int

getBottomMargin()

string

getCustomDictionary()

BBjColor

getDisabledTextColor()

boolean

getDragEnabled()

int

getHighlightOnFocus()

int

getLeftMargin()

string

getLocale()

int

getMaxSuggestions()

BBjVector

getMisspelledWords()

string

getPlaceholder()

BBjColor

getPlaceholderColor()

int

getRightMargin()

BBjColor

getSpellCheckColor()

string

getSpellCheckLanguage()

boolean

getSpellCheckOption(int option)

BBjVector

getSuggestions(string word)

int

getTopMargin()

void

ignoreWord(string word)  

boolean

isMisspelled(string word)

boolean

isSpellChecked()

void

removeWord(string word)

void

setBottomMargin(int margin)

void

setCustomDictionary(string filename)

void

setDisabledTextColor(BBjColor color!)

void

setDragEnabled(boolean enabled)

void

setHighlightOnFocus(int behavior)

void

setLeftMargin(int margin)

void

setLocale(string locale)

void

setMaxSuggestions(int count)

void

setPlaceholder(string placeholder)

void

setPlaceholderColor(BBjColor color!)

void

setRightMargin(int margin)

void

setSpellCheckColor(BBjColor color!)

void

setSpellChecked(boolean check)

void

setSpellCheckLanguage(string language)

void

setSpellCheckOption(int option, boolean value)

void

setTopMargin(int margin)


Constants

The following constants are used by the setSpellCheckOption and getSpellCheckOption methods:

CASE_SENSITIVE_OPT

Controls whether to check spelling with regard to differences in letter case (e.g., treating america and America as two separate words) or by ignoring differences in letter case. (e.g., treating america and America as the same word). Keeping this option enabled improves performance (because the spell check dictionaries are optimized for case-sensitive access) and ensures that capitalization errors are detected. You might disable this option when checking text entered in all-caps, for example.

IGNORE_ALL_CAPS_WORD_OPT

Controls whether the spell checker automatically skips (ignores) words containing just capital letters. If the text contains many abbreviations or acronyms, setting this option prevents them from being reported as spelling errors.

IGNORE_CAPPED_WORD_OPT

Controls whether the spell checker automatically skips (ignores) words starting with a capital letter. If the text contains many proper names, setting this option prevents them from being reported as spelling errors.

IGNORE_DOMAIN_NAMES_OPT

Controls whether the spell checker automatically skips (ignores) words which appear to be Internet domain names, URLs, email addresses, etc.

IGNORE_MIXED_CASE_OPT

Controls whether the spell checker automatically skips (ignores) words which contain a mixture of upper- and lower-case letters. If the text contains variable names, technical jargon, etc. (e.g., YearToDate, FmtString), setting this option prevents them from being reported as spelling errors.

IGNORE_MIXED_DIGITS_OPT

Controls whether the spell checker automatically skips (ignores) words which contain embedded digits. When checking general text, enabling this option will prevent strings like product codes from being reported as spelling errors.

REPORT_DOUBLED_WORD_OPT

The spell checker can automatically detect the same word appearing twice in a row (e.g., Minutes of the meeting were filed yesterday.) This option controls whether doubled words are reported as misspelled.

REPORT_MIXED_CASE_OPT

The spell checker can automatically detect words which have an unusual combination of upper- and lower-case letters (e.g., TUesday). This option controls whether mixed-case words are reported as misspelled.

REPORT_MIXED_DIGITS_OPT

The spell checker can automatically detect words which contain embedded digits, which might result from accidentally omitting a space (e.g., Monday14 August). This option controls whether words with embedded digits are reported as misspelled.

REPORT_UNCAPPED_OPT

Enable if check words should be reported whose first character is not capitalized.

SPLIT_CONTRACTED_WORDS_OPT

When this option is enabled, apostrophes will if necessary be treated as word separators, and each sub-word checked individually. This option is intended for use with the French and Italian dictionaries.

SPLIT_HYPHENATED_WORDS_OPT

When this option is enabled, hyphens ("-") will if necessary be treated as word separators, and each sub-word checked individually.

SPLIT_WORDS_OPT

When this option is enabled, words will if necessary be treated as a series of concatenated sub-words, and each sub-word checked individually. This option is intended for use with the German and Finnish dictionaries.

STRIP_POSSESSIVES_OPT

When this option is enabled, possessives of the form 's and s' will be removed from words before checking their spelling.

SUGGEST_SPLIT_WORDS_OPT

When this option is enabled, the Suggest function will attempt to split the misspelled word into two, and will offer the split words as suggestions if both are valid words. This is useful for correcting words incorrectly joined by a missing space -- e.g., if this option is enabled, the Suggest method would suggest the dog as a replacement for thedog.

The following constants are used by the setHighlightOnFocus and getHighlightOnFocus methods:

HIGHLIGHT_NONE

Contents of the control are never automatically highlighted when the control gets focus.

HIGHLIGHT_KEY

Contents of the control are automatically highlighted when the control gets focus by tabbing into it.

HIGHLIGHT_MOUSE

Contents of the control are automatically highlighted when the control gets focus by clicking into it with the mouse.

HIGHLIGHT_KEY_MOUSE

Contents of the control are automatically highlighted when the control gets focus by tabbing into it or clicking into it with the mouse.

HIGHLIGHT_FOCUS

Contents of the control are automatically highlighted when the control gets focus under program control.

HIGHLIGHT_FOCUS_OR_KEY

Contents of the control are automatically highlighted when the control gets focus under program control or by tabbing into it.

HIGHLIGHT_FOCUS_OR_MOUSE

Contents of the control are automatically highlighted when the control gets focus under program control or by clicking into it with the mouse.

HIGHLIGHT_ALL

Contents of the control are always automatically highlighted when the control gets focus.

Remarks

By default, the spell checker will attempt to use the language specified in STBL("!LOCALE"). If STBL("!LOCALE") cannot be reconciled to a supported language code, the spell checker will use "en_US" (American English). See TextControl::setSpellCheckLanguage for a complete list of supported language codes.

The default custom dictionary can be specified in STBL("!DICTIONARY"). If this global string is not set, the spell checker will create a custom dictionary named "CUSTOM.DIC".

Spell-checking in a thin client configuration requires extra jar files that are not included by default. Because the language dictionaries are fairly large and most applications do not use all languages, the dictionary files are not included in the standard thin-client jar configuration.  When deploying a client application that uses spell-checking, add the required dictionary files listed in BBj Classpath Overview to the cache archive.

Example

REM ' TextControl

SYSGUI=UNT
OPEN (SYSGUI)"X0"

Locale$ = stbl("!LOCALE","en_GB")
sysgui! = BBjAPI().getSysGui()
window! = sysgui!.addWindow(200,200,400,400,"Spell-Check Demo",$00010003$)
checkbox! = window!.addCheckBox(101,25,25,150,30,"Toggle SpellCheck",$0004$)
cedit! = window!.addCEdit(102,25,50,350,325,"",$0100$)
cedit!.setLineWrap(1)

gosub InitText
gosub setSpellChecked

CALLBACK(ON_CHECK_ON,setSpellChecked,checkbox!.getContextID(),checkbox!.getID())
CALLBACK(ON_CHECK_OFF,unsetSpellChecked,checkbox!.getContextID(),checkbox!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,sysgui!.getContext())

REM Process Events
PROCESS_EVENTS

APP_CLOSE:
RELEASE

setSpellChecked:
    cedit!.setSpellChecked(1)
return

unsetSpellChecked:
    cedit!.setSpellChecked(0)
return

InitText:
  Text! = new java.util.HashMap()
  while 1
    dread text$,err=*break
    cedit!.addParagraph(-1,text$)
  wend
return

data "CHAPTER I"
data "Down the Rabbit-Hole"
data "Alice was begining to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversation?'"

data "So she was considerring in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her."

data "There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, 'Oh dear! Oh dear! I shall be late!' (when she thought it over afterwards, it occured to her that she ought to have wondered at this, but at the time it all seemed quite natural); but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and burning with curiousity, she ran across the field after it, and fortunatly was just in time to see it pop down a large rabbit-hole under the hedge."

See Also

BBjAPI

BBjSysGui

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.