Cross-platform C SDK logo

Cross-platform C SDK

Edit

❮ Back
Next ❯
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.

Functions

Edit*edit_create (void)
Edit*edit_multiline (void)
voidedit_OnFilter (...)
voidedit_OnChange (...)
voidedit_text (...)
voidedit_font (...)
voidedit_align (...)
voidedit_passmode (...)
voidedit_editable (...)
voidedit_autoselect (...)
voidedit_tooltip (...)
voidedit_color (...)
voidedit_color_focus (...)
voidedit_bgcolor (...)
voidedit_bgcolor_focus (...)
voidedit_phtext (...)
voidedit_phcolor (...)
voidedit_phstyle (...)
const char_t*edit_get_text (...)

EditBox are small text boxes with editing capabilities. Like the Label they are of uniform format: The typeface and colors will affect the entire text (Figure 1). They are usually used to edit fields in forms, normally restricted to a single line, although they can also be extended to several of them. To edit texts with multiple attributes use TextView. In Hello Edit and UpDown! you have an example of use.


1. Filter texts

Depending on the value we are editing, it may be necessary to validate the text entered. We can do this at the end of editing or while we are writing. For the first case we will use the event edit_OnChange which will call the handler when the control has lost focus on the keyboard (Figure 2). If we want to implement more elaborate filters, that correct the text while writing we will use the event edit_OnFilter. For example in (Listing 1) we have a simple filter that only allows numeric characters (Figure 3).

  • Use edit_OnChange to validate the final text.
  • Use edit_OnFilter to detect and correct every user click.
  • Shows the change of keyboard focus between two edit boxes.
    Figure 2: The OnChange event is called when the control loses focus.
    Show the event after pressing a key in an edit box.
    Figure 3: The OnFilter event is called after each key press.
    Listing 1: Filter that only allows numeric characters.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    static void OnFilter(void *noused, Event *e)
    {
        const EvText *params = event_params(e, EvText);
        EvTextFilter *result = event_result(e, EvTextFilter);
        uint32_t i = 0, j = 0;
        while (params->text[i] != '\0')
        {
            if (params->text[i] >= '0' && params->text[i] <= '9')
            {
                result->text[j] = params->text[i];
                j += 1;
            }
    
            i += 1;
        }
    
        result->text[j] = '\0';
        result->apply = TRUE;
    }
    ...
    edit_OnFilter(edit1, listener(NULL, i_OnFilter, void));
    

edit_create ()

Create a text edit control.

Edit*
edit_create(void);

Return

The edit.


edit_multiline ()

Create a text editing control that allows multiple lines.

Edit*
edit_multiline(void);

Return

The edit.


edit_OnFilter ()

Set a function to filter the text while editing.

void
edit_OnFilter(Edit *edit,
              Listener *listener);
edit

The edit.

listener

Callback function to be called after each key press. In EvTextFilter from event_result filtered text will be returned.

Remarks

See Filter texts and GUI Events.


edit_OnChange ()

Set a function to detect when the text has changed.

void
edit_OnChange(Edit *edit,
              Listener *listener);
edit

The edit.

listener

Callback function to be called when the control loses focus on the keyboard, indicating the end of the edition.

Remarks

See GUI Events.


edit_text ()

Set the edit control text.

void
edit_text(Edit *edit,
          const char_t *text);
edit

The edit.

text

UTF8 C-string terminated in null character '\0'.


edit_font ()

Set the font of the edit control.

void
edit_font(Edit *edit,
          const Font *font);
edit

The edit.

font

Font.


edit_align ()

Set text alignment.

void
edit_align(Edit *edit,
           const align_t align);
edit

The edit.

align

Alignment.


edit_passmode ()

Activate the password mode, which will hide the typed characters.

void
edit_passmode(Edit *edit,
              const bool_t passmode);
edit

The edit.

passmode

Enable or disable password mode.


edit_editable ()

Enable or disable editing in the control.

void
edit_editable(Edit *edit,
              const bool_t is_editable);
edit

The edit.

is_editable

TRUEwill allow to edit the text (by default).


edit_autoselect ()

Activate or deactivate auto-selection of text.

void
edit_autoselect(Edit *edit,
                const bool_t autoselect);
edit

The edit.

autoselect

TRUE the control text will be fully selected when it receives focus.

Remarks

Default FALSE.


edit_tooltip ()

Assigns a tooltip to the edit control.

void
edit_tooltip(Edit *edit,
             const char_t *text);
edit

The edit.

text

UTF8 C-string terminated in null character '\0'.


edit_color ()

Set the text color.

void
edit_color(Edit *edit,
           const color_t color);
edit

The edit.

color

Text color.

Remarks

RGB values may not be fully portable. See Colors.


edit_color_focus ()

Sets the color of the text, when the control has the keyboard focus.

void
edit_color_focus(Edit *edit,
                 const color_t color);
edit

The edit.

color

Text color.

Remarks

RGB values may not be fully portable. See Colors.


edit_bgcolor ()

Set the background color.

void
edit_bgcolor(Edit *edit,
             const color_t color);
edit

The edit.

color

Background color.

Remarks

RGB values may not be fully portable. See Colors.


edit_bgcolor_focus ()

Sets the background color, when the control has keyboard focus.

void
edit_bgcolor_focus(Edit *edit,
                   const color_t color);
edit

The edit.

color

Background color.

Remarks

RGB values may not be fully portable. See Colors.


edit_phtext ()

Set an explanatory text for when the control is blank (placeholder).

void
edit_phtext(Edit *edit,
            const char_t *text);
edit

The edit.

text

UTF8 C-string terminated in null character '\0'.


edit_phcolor ()

Set the color of the placeholder text.

void
edit_phcolor(Edit *edit,
             const color_t color);
edit

The edit.

color

Text color.

Remarks

RGB values may not be fully portable. See Colors.


edit_phstyle ()

Set the font style for the placeholder.

void
edit_phstyle(Edit *edit,
             const uint32_t fstyle);
edit

The edit.

fstyle

Combination of values of fstyle_t.


edit_get_text ()

Get control text.

const char_t*
edit_get_text(const Edit *edit);
edit

The edit.

Return

UTF8 C-string terminated in null character '\0'.

❮ Back
Next ❯