mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Simplified Cocoa key input.
This commit is contained in:
parent
aec952e8dc
commit
6a7dbfee29
@ -436,20 +436,14 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
|
|
||||||
- (void)keyDown:(NSEvent *)event
|
- (void)keyDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
NSUInteger i, length;
|
_glfwInputKey(window, convertMacKeyCode([event keyCode]), GLFW_PRESS);
|
||||||
NSString* characters;
|
|
||||||
const int key = convertMacKeyCode([event keyCode]);
|
|
||||||
if (key == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_glfwInputKey(window, key, GLFW_PRESS);
|
|
||||||
|
|
||||||
if ([event modifierFlags] & NSCommandKeyMask)
|
if ([event modifierFlags] & NSCommandKeyMask)
|
||||||
[super keyDown:event];
|
[super keyDown:event];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
characters = [event characters];
|
NSString* characters = [event characters];
|
||||||
length = [characters length];
|
NSUInteger i, length = [characters length];
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
_glfwInputChar(window, [characters characterAtIndex:i]);
|
_glfwInputChar(window, [characters characterAtIndex:i]);
|
||||||
@ -476,9 +470,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
|
|
||||||
- (void)keyUp:(NSEvent *)event
|
- (void)keyUp:(NSEvent *)event
|
||||||
{
|
{
|
||||||
int key = convertMacKeyCode([event keyCode]);
|
_glfwInputKey(window, convertMacKeyCode([event keyCode]), GLFW_RELEASE);
|
||||||
if (key != -1)
|
|
||||||
_glfwInputKey(window, key, GLFW_RELEASE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollWheel:(NSEvent *)event
|
- (void)scrollWheel:(NSEvent *)event
|
||||||
|
Loading…
Reference in New Issue
Block a user