Retrieving text from a controlΒΆ

get_text()

Retrieve text from a control


SYNTAX

get_text(control_id)

Retrieve text from the control that has focus. This is particularly useful within an event function.

Normally the text will be tested by use of the EV_KEYSTROKE event. This is not enabled by default; it must be enabled for any control that is to generate it by means of the event_enable clause, e.g.:

event_enable = EV_DEFAULT | EV_KEYSTROKE

The key pressed is sent as the fifth argument to the event function if the control is a table, or as the third argument if it is any other control type.

The control_id may be any of the following types:

box_id

The function returns the current text in the textbox when an event (most commonly EV_KEYSTROKE) is generated while the textbox has focus.

table_id

get_text() can be used to retrieve the text in the currently focused cell in an editable table when a keystroke is typed in that cell. The cell must be of type TCT_TEXTBOX.

button_id

The function returns the button label.

other

get_text() currently returns a null string. This may change in the future.


NOTES

  • The on local and on global commands configure function keys or other special keys to call a function or subroutine. See the documentation on those commands for a full list of the keys that may be used.

  • The example program $SCULPTOR/examples/get_text.r demonstrates this function.


EXAMPLE

This event function displays the text typed so far when the user pre sses the F1 key:

!include <keycode.h>

!function ControlEvent(EventCode, Object, KeyCode) {
     switch (EventCode) {
          case == EV_KEYSTROKE:
               if (KeyCode == -KEY_F1) {
                    info "The text typed so far is'" + get_text(Object) + "'"
               }
               break
          ...
     }
}

RELATED TOPICS

Textboxes

Textbox events and functions

Tables

Table cell properties

Table events and functions

Buttons

Button events and functions

The EV_KEYSTROKE event

The include file keycode.h