HeaderPane
Main
Hide
Share Link
Print

Editing

An SftMask control edits its contents as an edit control does, within the rules of its mask: characters that do not fit are rejected, and deleting moves the following characters only to positions that accept them.

Clipboard

The SftMask.Copy, SftMask.Cut and SftMask.Paste methods and the keys Ctrl+C, Ctrl+X, Ctrl+V, Ctrl+Insert, Shift+Delete and Shift+Insert use the clipboard. The SftMask.ClipboardFormat property defines whether copied text includes the literals and prompt characters, and how pasted text is entered. A pasted text replaces the selection and is typed into the mask from the caret: the characters that fit are entered, or nothing if one of them does not fit and the SftMask.RejectInputOnFirstFailure property is set. A selection that contains password positions cannot be copied, cut or dragged. The SftMask.PrePaste event occurs before a text is pasted, so the application can change it or cancel the paste; a Paste overload pastes a given text instead of the clipboard's.

The SftMask.Clear method empties the control.

Undo

The SftMask.Undo method, Ctrl+Z and Ctrl+U undo the most recent change made by the user, up to 16 changes. Each typed character is a change of its own, as are a deletion, a cut, a paste, a drop, a spin, an entry chosen from the autocomplete list and the calculator's result. As in a TextBox, contents set by the application (the SftMask.Text, SftMask.Value, SftMask.Values and SftMask.SelectedText properties, the SftMask.Clear method) and a new mask clear the earlier changes. The SftMask.CanUndo property returns whether a change can be undone (never in a read-only control), and the SftMask.ClearUndo method forgets the earlier changes.

Context Menu

Right-clicking the control, Shift+F10 and the Menu key show the standard edit context menu of Windows, in the language of the system, with Undo, Cut, Copy, Paste, Delete and Select All. The SftMask.ShortcutsEnabled property turns off the context menu together with Ctrl+A and the clipboard and undo keys. An application can assign its own ContextMenuStrip instead.

Drag and Drop

The SftMask.DragMode property defines whether the selected text can be dragged: not at all (DragModeEnum.None, the default), by the control itself (DragModeEnum.Automatic), or by the application (DragModeEnum.Manual): pressing the mouse button on the selection then raises the SftMask.DragStarting event, where the application starts the drag operation and sets DragStartingEventArgs.Handled. With DragModeEnum.Automatic, the control drags the selected text with its literals; dropped on another control, the text is moved, or copied while Ctrl is held. With the AllowDrop property set, text dropped on the control is entered at the drop position, the characters that fit, and selected; text dragged within the control is moved, or copied while Ctrl is held. The SftMask.PrePaste event does not occur for a drop.

Input Method Editors

Input method editors for Chinese, Japanese and Korean compose their text at the caret, and the composed characters are entered into the mask as typed characters. The input method editor is turned off in a read-only control and for a mask without positions that accept letters, such as a numeric mask.

Modified Contents

The SftMask.Modified property tells whether the user changed the contents since the application last set it to false, and the SftMask.ModifiedChanged event occurs when it changes. Setting the contents in code does not set it.