Skip to main content
AKetc
Associate III
October 12, 2019
Solved

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

  • October 12, 2019
  • 3 replies
  • 759 views

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​ 

This topic has been closed for replies.
Best answer by Martin KJELDSEN

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

3 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
October 14, 2019

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
AKetcAuthor
Associate III
October 15, 2019

Thanks for the help. Really appreciate it.

Martin KJELDSEN
Principal III
October 15, 2019

Anytime!

/Martin