Input Attributes (XForms (Forms Library) - Version 1.2 (Rev. 4) A Graphical User Interface Toolkit for X)

Next: Input Remarks, Previous: Other Input Routines, Up: Part III Input Objects [Contents][Index]

### 18.5 Input Attributes

Never use `FL_NO_BOX` as the boxtype.

The first color argument (`col1`) to `fl_set_object_color()` controls the color of the input field when it is not selected and the second (`col2`) is the color when selected.

To change the color of the input text or the cursor use

    void fl_set_input_color(FL_OBJECT *obj, FL_COLOR tcol, FL_COLOR ccol);

Here `tcol` indicates the color of the text and `ccol` is the color of the cursor.

If you want to know the colors of the text and cursor use

    void fl_get_input_color(FL_OBJECT *obj, FL_COLOR *tcol, FL_COLOR *ccol);

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

    void fl_set_input_scrollbarsize(FL_OBJECT *obj, int hh, int vw);

where `hh` is the horizontal scrollbar height and `vw` is the vertical scrollbar width in pixels.

To determine the current settings for the horizontal scrollbar height and the vertical scrollbar width use

    void fl_get_input_scrollbarsize(FL_OBJECT *obj, int *hh, int *vw);

The default scrollbar types are `FL_HOR_THIN_SCROLLBAR` and `FL_VERT_THIN_SCROLLBAR`. There are two ways you can change the default. One way is to use `fl_set_defaults()` or `fl_set_scrollbar_type()` to set the application wide default (preferred); another way is to use `fl_get_object_component()` to get the object handle to the scrollbars and change the the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a structure of type `FL_EditKeymap` defined as follows:

    typedef struct {
        long del_prev_char;     /* delete previous char */
        long del_next_char;     /* delete next char */
        long del_prev_word;     /* delete previous word */
        long del_next_word;     /* delete next word */
        long del_to_eol;        /* delete from cursor to end of line */
        long del_to_bol;        /* delete from cursor to begin of line */
        long clear_field;       /* delete all */
        long del_to_eos;        /* not implemented */
        long backspace;         /* alternative for del_prev_char */

        long moveto_prev_line;  /* one line up */
        long moveto_next_line;  /* one line down */
        long moveto_prev_char;  /* one char left */
        long moveto_next_char;  /* one char right */
        long moveto_prev_word;  /* one word left */
        long moveto_next_word;  /* one word right */
        long moveto_prev_page;  /* one page up */
        long moveto_next_page;  /* one page down */
        long moveto_bol;        /* move to begining of line */
        long moveto_eol;        /* move to end of line */
        long moveto_bof;        /* move to begin of file */
        long moveto_eof;        /* move to end of file */

        long transpose;         /* switch two char positions*/
        long paste;             /* paste the edit buffer */
    } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

    void fl_set_input_editkeymap(const FL_EditKeymap *km);

with a filled or partially filled `FL_EditKeymap` structure. The unfilled members must be set to 0 so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Calling `fl_set_input_editkeymap()` with `km` set to `NULL` restores the default. All cursor keys (`<Left>`, `<Home>` etc.) are reserved and their meanings hard-coded, thus can’t be used in the mapping. For example, if you try to set `del_prev_char` to `<Home>`, pressing the `<Home>` key will not delete the previous character.

To obtain the current map of the edit keys use the function

    void fl_get_input_editkeymap(FL_EditKeymap *km);

with the `km` argument pointing of a user supplied structure which after the call will be set up with the current settings for the edit keys.

In filling the keymap structure, ASCII characters (i.e., characters with values below 128, including the control characters with values below 32) should be specified by their ASCII codes (`<Ctrl> C` is 3 etc.), while all others by their `Keysym`s (`XK_F1` etc.). Control and special character combinations can be obtained by adding `FL_CONTROL_MASK` to the `Keysym`. To specify `Meta` add `FL_ALT_MASK` to the key value.

    FL_EditKeymap ekm;
    memset(&ekm, 0, sizeof ekm);                  /* zero struct */

    ekm.del_prev_char = 8;                        /* <Backspace> */
    ekm.del_prev_word = 8 | FL_CONTROL_MASK;      /* <Ctrl><Backspace> */
    ekm.del_next_char = 127;                      /* <Delete> */
    ekm.del_prev_word = 'h' | FL_ALT_MASK;        /* <Meta>h */
    ekm.del_next_word = 127 | FL_ALT_MASK;        /* <Meta><Delete> */
    ekm.moveto_bof    = XK_F1;                    /* <F1> */
    ekm.moveto_eof    = XK_F1 | FL_CONTROL_MASK;  /* <Ctrl><F1> */

    fl_set_input_editkeymap(&ekm);

Note: In earlier versions of XForms (all version before 1.2) the default behaviour of the edit keys was slightly different which doesn’t fit modern user expectations, as was the way the way the edit keymap was to be set up. If you use XForms for some older application that makes massive use of the "classical" behaviour you can compile XForms to use the old behaviour by using the `--enable-classic-editkeys` option when configuring the library for compilation.

Next: Input Remarks, Previous: Other Input Routines, Up: Part III Input Objects [Contents][Index]