class edit


NAME

edit - Edit a single line of text

SYNOPSIS

class edit : public window

DESCRIPTION

An edit object contains a single line of text that can be edited. A text cursor is drawn in the text to mark the position in which characters typed from the keyboard will be inserted. The cursor can be moved by using the left and right cursor keys or by pressing the mouse button in the text. The window in which the text is displayed does not need to be large enough to display the whole line of text. If the text exceeds the size of the window, only a part of the text is visible at a time. The user can scroll the text horizontally by moving the text cursor with the cursor keys.

Handled events

Buttonpress sets the focus to the edit window. The X server will send a FocusIn event as a result of the SetFocus

Mouse click deselects any selection but does not change the cut buffer.

Button release is the end of a click or the end of a drag.

MotionNotify signifies a drag (only with button 1 pressed).

Four events, EnterNotify, LeaveNotify, FocusIn and FocusOut, are tracked to tell if the edit object has the keyboard focus. (see Keyboard focus below).

Sent messages

EDIT_ENTERED - When the Enter key (normal or keypad) is pressed on the edit window. This is the default action of the overridable function enter()

EDIT_FOCUSLOST - When the (implicit or explicit) focus is lost. This is the default action of the overridable function focuslost()

Edit keys

Backspace: remove character before cursor position

Delete : remove character after cursor position

Return or Enter: send a EDIT_ENTERED message to the parent window through virtual function enter().

Cursor left/right : move cursor. If the cursor would be moved outside the window, the text is moved one quarter of the window's size to compensate.

Keyboard focus

Implicit focus by moving the mouse on the edit window. The focus is lost when the mouse is moved outside the edit window.

Explicit focus by clicking the left mouse button. The focus remains until set to another window.

Four events, EnterNotify, LeaveNotify, FocusIn and FocusOut, are tracked to tell if the edit object has the keyboard focus. These four events drive the state diagram shown below:

Copy and Paste

Copy by dragging the left mouse button. The selected text is stores in the X cut buffer.

Double-click selects the whole text (not implemented yet)

Selection is undone by a keypress or left mouse button. If the key is an edit key, the selected text is deleted first. Keys that would not normally change the text do not delete the selected text.

Paste at the cursor position by clicking the middle mouse button. The cursor position is not changed.

Member Functions

edit

constructor and destructor

operator =

Set the contents of the text. by assigning a string

operator string &

Get the contents of the text into a string

SelectAll

Select the entire string for copy or delete

ClearSelection

De-select the selected text

DeleteSelection

Delete the selected text from the string

BUGS

Start a drag inside selected text to move the selected text (drag & drop): Not implemented

Double click to select all text: Not implemented

SEE ALSO

DIAGNOSTICS

Source Code