- Main Page
- Packages
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# smjg.libs.sdwf.control.EditBox Class Reference

The smjg.libs.sdwf.control.EditBox class interfaces a single-line or multi-line text edit control. More...

Inheritance diagram for smjg.libs.sdwf.control.EditBox:

List of all members.

## Public Member Functions
| this (Dialog parent, int id)
| Constructs an EditBox object to interface a given edit control.
| this (WindowBase parent, int id, string text, Rect position)
| Constructs an edit box to be created at runtime.
| this (FrameWindow parent, int id, string text)
| Constructs an edit box to be used as the client pane of a FrameWindow.
bool | undo ()
| Undoes the last edit in this edit box.
void | getSelection (out uint begin, out uint end)
| Gets the range of the current selection.
void | setSelection (uint begin, uint end)
| Sets the range of the current selection.
void | selectAll ()
| Selects the entire text of the edit control.
void | scrollToCaret ()
| Ensures that the caret is in view.
void | insertText (string t, bool allowUndo=true)
| Inserts text in the edit control at the current cursor position.
Properties
char[] | text ()
| The text currently in this edit box.
string | text (string t)
| The text currently in this edit box.
bool | canUndo ()
| Whether an edit can be undone.
bool | canUndo (bool c)
| Whether an edit can be undone.
bool | softLineBreaks ()
| Whether soft line breaks will be stored in the text property, as the sequence "\r\r\n".
bool | softLineBreaks (bool s)
| Whether soft line breaks will be stored in the text property, as the sequence "\r\r\n".
uint | scrollPosition ()
| The position to which the edit control is scrolled.
uint | scrollPosition (uint pos)
| The position to which the edit control is scrolled.
uint | lines ()
| The number of lines of text present in a multi-line edit box.
uint | maxLength (uint len)
| The maximum number of characters that may be entered in this edit box.
uint | maxLength ()
| The maximum number of characters that may be entered in this edit box.
bool | modified ()
| A flag automatically set to true when the edit box's contents are changed.
bool | modified (bool m)
| A flag automatically set to true when the edit box's contents are changed.
char | passwordChar ()
| The character by which text will be masked, as to conceal a password being entered.
char | passwordChar (char c)
| The character by which text will be masked, as to conceal a password being entered.
bool | readOnly ()
| Whether this control is read-only.
bool | readOnly (bool r)
| Whether this control is read-only.
bool | hasSelection ()
| Whether text is selected in this edit box.
char[] | selectedText ()
| Gets the selected text.
## Public Attributes
mixin | EditOperations

## Detailed Description

The smjg.libs.sdwf.control.EditBox class interfaces a single-line or multi-line text edit control.

Todo:
  add more features, possibly including: line retrieval and char-index/line-index conversion, formatting rectangle, tab stops, custom word-breaking algorithms

## Constructor & Destructor Documentation

smjg.libs.sdwf.control.EditBox.this | ( | Dialog | parent,
|  | int | id |
| ) |  |  |

Constructs an EditBox object to interface a given edit control.

Parameters:

  | parent | the dialog on which the control is placed.
  | id | numeric ID of the control.

Precondition:
  The parent interface element must already have been created. EditBox objects should be constructed in an overridden Dialog.setup method, not in the constructor of a Dialog subclass.

Status:
  done

Reimplemented from smjg.libs.sdwf.control.Control.

smjg.libs.sdwf.control.EditBox.this | ( | WindowBase | parent,
|  | int | id,
|  | string | text,
|  | Rect | position |
| ) |  |  |

Constructs an edit box to be created at runtime.

Parameters:

  | parent | the window or dialog on which the edit box will be placed.
  | id | numeric ID that the edit box will have.
  | text | the edit box's caption text.
  | position | the position on the parent window where the edit box will be placed.

Since:
  0.4

Status:
  done

smjg.libs.sdwf.control.EditBox.this | ( | FrameWindow | parent,
|  | int | id,
|  | string | text |
| ) |  |  |

Constructs an edit box to be used as the client pane of a FrameWindow.

Parameters:

  | parent | the frame window in which this edit box will be framed.
  | id | numeric ID that the edit box will have.
  | text | the edit box's initial text.

Since:
  0.4

Status:
  done

## Member Function Documentation

char [] smjg.libs.sdwf.control.EditBox.text | ( |  | ) |

The text currently in this edit box.

Reimplemented from smjg.libs.sdwf.windowbase.WindowBase.

string smjg.libs.sdwf.control.EditBox.text | ( | string | t | ) |

The text currently in this edit box.

Exceptions:

  | ControlException | if the text is too long for an edit box.

Status:
  done

Reimplemented from smjg.libs.sdwf.windowbase.WindowBase.

bool smjg.libs.sdwf.control.EditBox.canUndo | ( |  | ) |

Whether an edit can be undone.

Status:
  test

bool smjg.libs.sdwf.control.EditBox.canUndo | ( | bool | c | ) |

Whether an edit can be undone.

Only setting to `false` has an effect, clearing the edit box's undo buffer.

Status:
  test

bool smjg.libs.sdwf.control.EditBox.softLineBreaks | ( |  | ) |

Whether soft line breaks will be stored in the text property, as the sequence "\r\r\n".

Since:
  0.52

bool smjg.libs.sdwf.control.EditBox.softLineBreaks | ( | bool | s | ) |

Whether soft line breaks will be stored in the text property, as the sequence "\r\r\n".

Status:
  test

Todo:
  possibly implement read

uint smjg.libs.sdwf.control.EditBox.scrollPosition | ( |  | ) |

The position to which the edit control is scrolled.

Returns:
  for a multi-line edit box, the zero-based index of the uppermost visible line.

Bug:
  For a single-line edit box, it should return the zero-based index of the leftmost visible character. However, for some strange reason it is always returning zero.

uint smjg.libs.sdwf.control.EditBox.scrollPosition | ( | uint | pos | ) |

The position to which the edit control is scrolled.

Parameters:

  | pos | for a multi-line edit box, the zero-based index of the uppermost visible line.

Since:
  0.52

Bug:
  No effect on a single-line edit box. The Windows API documentation isn't crystal clear on whether EM_LINESCROLL is supposed to work at all on such things.

uint smjg.libs.sdwf.control.EditBox.lines | ( |  | ) |

The number of lines of text present in a multi-line edit box.

Return values:

  | 1 | if the box is empty

Status:
  test

uint smjg.libs.sdwf.control.EditBox.maxLength | ( | uint | len | ) |

The maximum number of characters that may be entered in this edit box.

Status:
  done

uint smjg.libs.sdwf.control.EditBox.maxLength | ( |  | ) |

The maximum number of characters that may be entered in this edit box.

Since:
  0.51

bool smjg.libs.sdwf.control.EditBox.modified | ( |  | ) |

A flag automatically set to true when the edit box's contents are changed.

Status:
  done

bool smjg.libs.sdwf.control.EditBox.modified | ( | bool | m | ) |

A flag automatically set to true when the edit box's contents are changed.

Status:
  done

char smjg.libs.sdwf.control.EditBox.passwordChar | ( |  | ) |

The character by which text will be masked, as to conceal a password being entered.

A value of '' signifies that no masking takes place.

Status:
  test

char smjg.libs.sdwf.control.EditBox.passwordChar | ( | char | c | ) |

The character by which text will be masked, as to conceal a password being entered.

A value of '' signifies that no masking takes place.

Status:
  test

bool smjg.libs.sdwf.control.EditBox.readOnly | ( |  | ) |

Whether this control is read-only.

Since:
  0.52

bool smjg.libs.sdwf.control.EditBox.readOnly | ( | bool | r | ) |

Whether this control is read-only.

Since:
  0.4 (previously buggy beyond use)

Status:
  done

bool smjg.libs.sdwf.control.EditBox.hasSelection | ( |  | ) |

Whether text is selected in this edit box.

Since:
  0.4

Status:
  done

char [] smjg.libs.sdwf.control.EditBox.selectedText | ( |  | ) |

Gets the selected text.

Returns:
  the selected text, or `null` if no text is selected.

Since:
  0.4

Status:
  done

bool smjg.libs.sdwf.control.EditBox.undo | ( |  | ) |

Undoes the last edit in this edit box.

Return values:

  | true | there turned out to be something to undo, or this is a single-line edit box. (This is due to an eccentricity in the Windows API.)
  | false | in a multi-line edit box, there was nothing to undo.

Status:
  done

void smjg.libs.sdwf.control.EditBox.getSelection | ( | out uint | begin,
|  | out uint | end |
| ) |  |  |

Gets the range of the current selection.

Parameters:

  | begin | variable to receive the beginning character position.
  | end | variable to receive the ending character position.

Note:
  Like D slices, the character indexed by `begin` is just inside the selection, and that indexed by `end` is just outside. If `begin == end`, then nothing is selected, and the value is the current cursor position. `begin <= end` will always hold regardless of the direction in which the selection was made.

Since:
  0.4

Status:
  done

void smjg.libs.sdwf.control.EditBox.setSelection | ( | uint | begin,
|  | uint | end |
| ) |  |  |

Sets the range of the current selection.

Parameters:

  | begin | the beginning character position.
  | end | the ending character position, or `uint.max` to select to the end.

Note:
  Like D slices, the character indexed by `begin` is just inside the selection, and that indexed by `end` is just outside. If `begin == end`, then nothing is selected, and the value becomes the current cursor position.

Since:
  0.4

Status:
  done

void smjg.libs.sdwf.control.EditBox.selectAll | ( |  | ) |

Selects the entire text of the edit control.

Since:
  0.4

Status:
  done

void smjg.libs.sdwf.control.EditBox.scrollToCaret | ( |  | ) |

Ensures that the caret is in view.

Since:
  0.4

Status:
  done

void smjg.libs.sdwf.control.EditBox.insertText | ( | string | t,
|  | bool | allowUndo = `true` |
| ) |  |  |

Inserts text in the edit control at the current cursor position.

If text is selected, it will be replaced.

Since:
  0.4

Status:
  done

## Member Data Documentation

mixin smjg.libs.sdwf.control.EditBox.EditOperations

The documentation for this class was generated from the following file:

- control.d