cancel
Showing results for 
Search instead for 
Did you mean: 

Use CustomKeyboard from the example to override my MainView's text area.

AKetc
Associate III

Hello everyone,

I am trying to build an application where I can copy whatever is displayed on the CusotmKeyboard's text area to my own custom text area in my MainView. The keyboard I am referring to is the one provided with the examples . I would really appreciate any help regarding this problem.

@Martin KJELDSEN​ 

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @AKetc​,

You can copy from one TextArea to another by using the following method from the Unicode class.

    /**
     * @fn static uint16_t Unicode::strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars);
     *
     * @brief Copy a string to a destination buffer, UnicodeChar to UnicodeChar version.
     *
     *        Copy a string to a destination buffer, UnicodeChar to UnicodeChar version. Stops if it
     *        encounters a zero-termination, in which case the zero-termination is included in
     *        the destination string. Otherwise copies maxchars.
     *
     * @param [out] dst The destination buffer. Must have a size of at least maxchars.
     * @param [in] src  The source string (UnicodeChars)
     * @param maxchars  Maximum number of characters to copy.
     *
     * @return The number of characters copied (excluding zero-termination if encountered)
     *
     * @warning If there is no null-termination among the first n UnicodeChars of src,
     *          the string placed in destination will NOT be zero-terminated!
     */
    static uint16_t strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars);

You should be able to use this to get the UnicodeChar array from your Keyboard Class and copy it into a TextArea in your view.

/Martin

View solution in original post

3 REPLIES 3
Martin KJELDSEN
Chief III

Hi @AKetc​,

You can copy from one TextArea to another by using the following method from the Unicode class.

    /**
     * @fn static uint16_t Unicode::strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars);
     *
     * @brief Copy a string to a destination buffer, UnicodeChar to UnicodeChar version.
     *
     *        Copy a string to a destination buffer, UnicodeChar to UnicodeChar version. Stops if it
     *        encounters a zero-termination, in which case the zero-termination is included in
     *        the destination string. Otherwise copies maxchars.
     *
     * @param [out] dst The destination buffer. Must have a size of at least maxchars.
     * @param [in] src  The source string (UnicodeChars)
     * @param maxchars  Maximum number of characters to copy.
     *
     * @return The number of characters copied (excluding zero-termination if encountered)
     *
     * @warning If there is no null-termination among the first n UnicodeChars of src,
     *          the string placed in destination will NOT be zero-terminated!
     */
    static uint16_t strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars);

You should be able to use this to get the UnicodeChar array from your Keyboard Class and copy it into a TextArea in your view.

/Martin

AKetc
Associate III

Thanks for the help. Really appreciate it.

Martin KJELDSEN
Chief III

Anytime!

/Martin