WantSpecial Property

Purpose

Changes the actions of the ENTER and/or TAB keys within a multiline TextBox or RichEdit control.

Syntax

object.WantSpecial [ = value ]

object:Textbox, RichEdit Ocx

Description

WantSpecial = 1 specifies that a Carriage Return and Line Feed (CRLF) be inserted when the user presses the ENTER key while entering text into a multiple-line edit control in a form rather than activating the form’s default pushbutton. Note that if there is no default command button, then ENTER automatically enters a CRLF within the object; similarly, the use of Ctrl+ENTER always enters a CRLF within the object, regardless of whether there is a default command button or not. This style has no effect on a single-line edit control.

WantSpecial = 2 prevents the TAB key moving the focus to the next control in a TextBox or RichEdit control; this setting also converts any Shift+TAB key combination, which would normally move the focus to the previous control, into a tab. Note that the Ctrl+TAB key combination always inserts a tab regardless of this setting.

WantSpecial = 3 enables both options (TAB & ENTER).

Example

Ocx TextBox txt = "", 10, 10, 200, 80 : .MultiLine = True : .BorderStyle = 1

Ocx CheckBox chk(1) = "Allow TAB within TextBox", 220, 10, 160, 14 : chk(1).TabStop = False

Ocx CheckBox chk(0) = "Restrict ENTER to TextBox", 220, 25, 160, 14 : chk(0).TabStop = False

Ocx Command cmd = "Close", 60, 100, 100, 22 : cmd.Default = True

Do : Sleep : Until Me Is Nothing

 

Sub chk_Click(Index%)

Local Int ws = txt.WantSpecial

Bchg ws, Index%

txt.WantSpecial = ws

EndSub

 

Sub cmd_Click

Me.Close

EndSub

See Also

TextBox, RichEdit

{Created by Sjouke Hamstra; Last updated: 29/06/2015 by James Gaite}