Shiny Language Reference

Language Reference > User Interface > Memo Boxes


setmemoboxacceptret

setmemoboxacceptret(int ID, bool AllowReturn);

 

Controls whether the memobox allows line feeds (newlines)

The SETMEMOBOXACCEPTRET statement controls how the memobox responds to the user pressing the Enter (Return) key. By default, pressing the Enter key in a memobox creates a new line by inserting a line feed ("\n"). This is the same behaviour found in all text editors. However this statement can configure the memobox to remove its own focus when the Enter key is pressed. This is useful where multiline text entry isn't allowed, or where Enter should be used to "commit" the text.

Note that this state also controls whether a notification of MEMOBOX_ENTER is sent to the membox's event handler function. When the memobox accepts Enter keypresses as new lines (when SETMEMOBOXACCEPTRET is called with the second parameter set to TRUE), no MEMOBOX_ENTER notification is sent. When the memobox does not accept keypresses as new lines the MEMOBOX_ENTER notification will be sent.

Memobox behaviour can be altered at any time as SETMEMOBOXACCEPTRET doesn't affect the existing contents of the control.

All memoboxes accept Enter keypresses as new lines by default.

 

Parameters

ID

The control ID of the control you wish to change the style of

AllowReturn

When TRUE, the memobox accepts an Enter keypress as an instruction to insert a new line. When FALSE, the memobox defocuses when the Enter key is pressed.

 

Return Value

None

 

Example Code

// Create the memo box X: 10, Y:10 and sized 150*70
int iMemoBoxID = creatememobox(1, 10, 10, 150, 70);

// Set the memobox text to "Hello World"
setcaption(iMemoBoxID, "Hello World");

// Tell the memobox not to allow newlines
setmemoboxacceptret(iMemoBoxID, False);