Add API: SetPreeditCallback
This is for GLFW3 Preedit Callback: glfwSetPreeditCallback
This commit is contained in:
parent
b432aa2b9c
commit
71bb40a9e4
|
|
@ -118,6 +118,7 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s
|
|||
// Input callbacks events
|
||||
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
|
||||
static void CharCallback(GLFWwindow *window, unsigned int codepoint); // GLFW3 Char Callback, runs on key pressed (get codepoint value)
|
||||
static void PreeditCallbackInner(GLFWwindow *window, int preeditLength, unsigned int *preeditString, int blockCount, int *blockSizes, int focusedBlock, int caret); // GLFW3 Preedit Callback
|
||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move
|
||||
static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Scrolling Callback, runs on mouse wheel
|
||||
|
|
@ -1598,6 +1599,7 @@ int InitPlatform(void)
|
|||
// Set input callback events
|
||||
glfwSetKeyCallback(platform.handle, KeyCallback);
|
||||
glfwSetCharCallback(platform.handle, CharCallback);
|
||||
glfwSetPreeditCallback(platform.handle, PreeditCallbackInner);
|
||||
glfwSetMouseButtonCallback(platform.handle, MouseButtonCallback);
|
||||
glfwSetCursorPosCallback(platform.handle, MouseCursorPosCallback); // Track mouse position changes
|
||||
glfwSetScrollCallback(platform.handle, MouseScrollCallback);
|
||||
|
|
@ -1782,6 +1784,13 @@ static void CharCallback(GLFWwindow *window, unsigned int codepoint)
|
|||
}
|
||||
}
|
||||
|
||||
// GLFW3 Preedit Callback
|
||||
static void PreeditCallbackInner(GLFWwindow *window, int preeditLength, unsigned int *preeditString, int blockCount, int *blockSizes, int focusedBlock, int caret)
|
||||
{
|
||||
if (!CORE.Input.Keyboard.preeditCallback) return;
|
||||
CORE.Input.Keyboard.preeditCallback(preeditLength, (int *)preeditString, blockCount, blockSizes, focusedBlock, caret);
|
||||
}
|
||||
|
||||
// GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s
|
|||
// Input callbacks events
|
||||
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
|
||||
static void CharCallback(GLFWwindow *window, unsigned int key); // GLFW3 Char Key Callback, runs on key pressed (get char value)
|
||||
static void PreeditCallbackInner(GLFWwindow *window, int preeditLength, unsigned int *preeditString, int blockCount, int *blockSizes, int focusedBlock, int caret); // GLFW3 Preedit Callback
|
||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move
|
||||
static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Srolling Callback, runs on mouse wheel
|
||||
|
|
@ -1219,6 +1220,7 @@ int InitPlatform(void)
|
|||
// Set input callback events
|
||||
glfwSetKeyCallback(platform.handle, KeyCallback);
|
||||
glfwSetCharCallback(platform.handle, CharCallback);
|
||||
glfwSetPreeditCallback(platform.handle, PreeditCallbackInner);
|
||||
glfwSetMouseButtonCallback(platform.handle, MouseButtonCallback);
|
||||
glfwSetCursorPosCallback(platform.handle, MouseCursorPosCallback); // Track mouse position changes
|
||||
glfwSetScrollCallback(platform.handle, MouseScrollCallback);
|
||||
|
|
@ -1453,6 +1455,13 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
|
|||
}
|
||||
}
|
||||
|
||||
// GLFW3 Preedit Callback
|
||||
static void PreeditCallbackInner(GLFWwindow *window, int preeditLength, unsigned int *preeditString, int blockCount, int *blockSizes, int focusedBlock, int caret)
|
||||
{
|
||||
if (!CORE.Input.Keyboard.preeditCallback) return;
|
||||
CORE.Input.Keyboard.preeditCallback(preeditLength, (int *)preeditString, blockCount, blockSizes, focusedBlock, caret);
|
||||
}
|
||||
|
||||
// GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1152,6 +1152,14 @@ RLAPI void PlayAutomationEvent(AutomationEvent event);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
// Callback for preedit text.
|
||||
// preeditLength: The length of preedit text
|
||||
// preeditString: The preedit text (unicode)
|
||||
// blockCount: The number of all converting blocks
|
||||
// blockSizes: The size of each converting block
|
||||
// focusedBlock: The index of the current converting block
|
||||
// caret: The index of the caret in preeditString
|
||||
typedef void (*PreeditCallback)(int preeditLength, int *preeditString, int blockCount, int *blockSizes, int focusedBlock, int caret);
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once
|
||||
|
|
@ -1162,6 +1170,7 @@ RLAPI bool IsKeyUp(int key); // Check if a key
|
|||
RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty
|
||||
RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
RLAPI void SetPreeditCallback(PreeditCallback callback); // Set a callback for preedit
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available
|
||||
|
|
|
|||
|
|
@ -306,6 +306,8 @@ typedef struct CoreData {
|
|||
int charPressedQueue[MAX_CHAR_PRESSED_QUEUE]; // Input characters queue (unicode)
|
||||
int charPressedQueueCount; // Input characters queue count
|
||||
|
||||
PreeditCallback preeditCallback; // Preedit callback
|
||||
|
||||
} Keyboard;
|
||||
struct {
|
||||
Vector2 offset; // Mouse offset
|
||||
|
|
@ -2863,6 +2865,12 @@ int GetCharPressed(void)
|
|||
return value;
|
||||
}
|
||||
|
||||
// Set a callback for preedit
|
||||
void SetPreeditCallback(PreeditCallback callback)
|
||||
{
|
||||
CORE.Input.Keyboard.preeditCallback = callback;
|
||||
}
|
||||
|
||||
// Set a custom key to exit program
|
||||
// NOTE: default exitKey is set to ESCAPE
|
||||
void SetExitKey(int key)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user