diff --git a/docs/input.dox b/docs/input.dox index dbd41f125..814e1ea8d 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -235,36 +235,42 @@ glfwSetPreeditCallback(window, preedit_callback); The callback function receives chunk of text and focused block information. @code -static void preedit_callback(GLFWwindow* window, int strLength, unsigned int* string, int blockLength, int* blocks, int focusedBlock) { +void preedit_callback(GLFWwindow* window, + int preedit_length, + unsigned int* preedit_string, + int block_count, + int* block_sizes, + int focused_block) +{ } @endcode -strLength and string parameter represent whole preedit text. Each character of the preedit string is a codepoint like @ref input_char. +"preedit_length" and "preedit_string" parameter represent whole preedit text. Each character of the preedit string is a codepoint like @ref input_char. If you want to type the text "寿司(sushi)", Usually the callback is called several times like the following sequence: -# key event: s --# preedit: [string: "s", block: [1], focusedBlock: 0] +-# preedit: [preedit_string: "s", block_sizes: [1], focused_block: 0] -# key event: u --# preedit: [string: "す", block: [1], focusedBlock: 0] +-# preedit: [preedit_string: "す", block_sizes: [1], focused_block: 0] -# key event: s --# preedit: [string: "すs", block: [2], focusedBlock: 0] +-# preedit: [preedit_string: "すs", block_sizes: [2], focused_block: 0] -# key event: h --# preedit: [string: "すsh", block: [2], focusedBlock: 0] +-# preedit: [preedit_string: "すsh", block_sizes: [2], focused_block: 0] -# key event: i --# preedit: [string: "すし", block: [2], focusedBlock: 0] +-# preedit: [preedit_string: "すし", block_sizes: [2], focused_block: 0] -# key event: ' ' --# preedit: [string: "寿司", block: [2], focusedBlock: 0] +-# preedit: [preedit_string: "寿司", block_sizes: [2], focused_block: 0] -# char: '寿' -# char: '司' --# preedit: [string: "", block: [], focusedBlock: 0] +-# preedit: [preedit_string: "", block_sizes: [], focused_block: 0] If preedit text includes several semantic blocks, preedit callbacks returns several blocks after a space key pressed: --# preedit: [string: "わたしはすしをたべます", block: [11], focusedBlock: 0] --# preedit: [string: "私は寿司を食べます", block: [2, 7], focusedBlock: 1] +-# preedit: [preedit_string: "わたしはすしをたべます", block_sizes: [11], focused_block: 0] +-# preedit: [preedit_string: "私は寿司を食べます", block_sizes: [2, 7], focused_block: 1] -"blocks" is a list of block length. The above case, it contains the following blocks and second block is focused. +"block_sizes" is a list of block length. The above case, it contains the following blocks and second block is focused. - 私は - [寿司を食べます] diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index d8e62ecc3..0f208a68b 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1883,11 +1883,11 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int * This is the function pointer type for preedit callback functions. * * @param[in] window The window that received the event. - * @param[in] length Preedit string length. - * @param[in] string Preedit string. - * @param[in] count Attributed block count. - * @param[in] blocksizes List of attributed block size. - * @param[in] focusedblock Focused block index. + * @param[in] preedit_length Preedit string length. + * @param[in] preedit_string Preedit string. + * @param[in] block_count Attributed block count. + * @param[in] block_sizes List of attributed block size. + * @param[in] focused_block Focused block index. * * @sa @ref preedit * @sa glfwSetPreeditCallback @@ -1898,7 +1898,7 @@ typedef void (* GLFWpreeditfun)(GLFWwindow* window, int preedit_length, unsigned int* preedit_string, int block_count, - int* block_sizes_list, + int* block_sizes, int focused_block); /*! @brief The function pointer type for IME status change callbacks. @@ -5261,6 +5261,18 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * callback. * @return The previously set callback, or `NULL` if no callback was set or an * error occurred. + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, + int preedit_length, + unsigned int* preedit_string, + int block_count, + int* block_sizes, + int focused_block) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWpreeditfun). * * @par Thread Safety * This function may only be called from the main thread. @@ -5283,6 +5295,13 @@ GLFWAPI GLFWpreeditfun glfwSetPreeditCallback(GLFWwindow* window, GLFWpreeditfun * callback. * @return The previously set callback, or `NULL` if no callback was set or an * error occurred. + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWimestatusfun). * * @par Thread Safety * This function may only be called from the main thread.