mirror of
https://github.com/glfw/glfw.git
synced 2024-11-23 02:25:10 +00:00
Implemented cursor enter/leave for OS X.
This commit is contained in:
parent
466246670f
commit
8e4e70d7a4
@ -292,6 +292,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
@interface GLFWContentView : NSView
|
@interface GLFWContentView : NSView
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
|
NSTrackingArea* trackingArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;
|
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;
|
||||||
@ -304,11 +305,22 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
|
{
|
||||||
window = initWindow;
|
window = initWindow;
|
||||||
|
trackingArea = nil;
|
||||||
|
|
||||||
|
[self updateTrackingAreas];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)dealloc
|
||||||
|
{
|
||||||
|
[trackingArea release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)isOpaque
|
- (BOOL)isOpaque
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
@ -384,6 +396,36 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
_glfwInputMouseClick(window, [event buttonNumber], GLFW_RELEASE);
|
_glfwInputMouseClick(window, [event buttonNumber], GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)mouseExited:(NSEvent *)event
|
||||||
|
{
|
||||||
|
_glfwInputCursorEnter(window, GL_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseEntered:(NSEvent *)event
|
||||||
|
{
|
||||||
|
_glfwInputCursorEnter(window, GL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)updateTrackingAreas
|
||||||
|
{
|
||||||
|
if (trackingArea != nil)
|
||||||
|
{
|
||||||
|
[self removeTrackingArea:trackingArea];
|
||||||
|
[trackingArea release];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
|
||||||
|
NSTrackingActiveAlways |
|
||||||
|
NSTrackingInVisibleRect;
|
||||||
|
|
||||||
|
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||||
|
options:options
|
||||||
|
owner:self
|
||||||
|
userInfo:nil];
|
||||||
|
|
||||||
|
[self addTrackingArea:trackingArea];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)keyDown:(NSEvent *)event
|
- (void)keyDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
NSUInteger i, length;
|
NSUInteger i, length;
|
||||||
|
Loading…
Reference in New Issue
Block a user