Improved function GetKeyPressed()
To support multiple keys (including function keys)
This commit is contained in:
parent
d0e7195a16
commit
6ee5718b2e
2 changed files with 15 additions and 11 deletions
|
@ -1735,10 +1735,11 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
TakeScreenshot();
|
TakeScreenshot();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else currentKeyState[key] = action;
|
else
|
||||||
|
{
|
||||||
// TODO: Review (and remove) this HACK for GuiTextBox, to deteck back key
|
currentKeyState[key] = action;
|
||||||
if ((key == 259) && (action == GLFW_PRESS)) lastKeyPressed = 3;
|
if (action == GLFW_PRESS) lastKeyPressed = key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLFW3 Mouse Button Callback, runs on mouse button pressed
|
// GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||||
|
|
|
@ -790,10 +790,10 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue)
|
||||||
char *GuiTextBox(Rectangle bounds, char *text)
|
char *GuiTextBox(Rectangle bounds, char *text)
|
||||||
{
|
{
|
||||||
#define MAX_CHARS_LENGTH 20
|
#define MAX_CHARS_LENGTH 20
|
||||||
#define KEY_BACKSPACE_TEXT 3
|
#define KEY_BACKSPACE_TEXT 259 // GLFW BACKSPACE: 3 + 256
|
||||||
|
|
||||||
int initPos = bounds.x + 4;
|
int initPos = bounds.x + 4;
|
||||||
char letter = -1;
|
int letter = -1;
|
||||||
static int framesCounter = 0;
|
static int framesCounter = 0;
|
||||||
Vector2 mousePoint = GetMousePosition();
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
|
@ -821,18 +821,21 @@ char *GuiTextBox(Rectangle bounds, char *text)
|
||||||
text[MAX_CHARS_LENGTH - 1] = '\0';
|
text[MAX_CHARS_LENGTH - 1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if ((letter >= 32) && (letter < 127))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CHARS_LENGTH; i++)
|
for (int i = 0; i < MAX_CHARS_LENGTH; i++)
|
||||||
{
|
{
|
||||||
if (text[i] == '\0')
|
if (text[i] == '\0')
|
||||||
{
|
{
|
||||||
text[i] = letter;
|
text[i] = (char)letter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw control
|
// Draw control
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue