mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
parent
aa4203fd54
commit
833837b427
@ -41,6 +41,8 @@ namespace sf {
|
||||
///
|
||||
/// Handle event and send them back to the requester.
|
||||
///
|
||||
/// NSTrackingArea is used to keep track of mouse events.
|
||||
///
|
||||
/// In order to send correct mouse coordonate to the requester when
|
||||
/// the window is in fullscreen we use m_realSize to represent the
|
||||
/// back buffer size (see SFWindowController). If 'm_realSize' is
|
||||
@ -54,8 +56,8 @@ namespace sf {
|
||||
@interface SFOpenGLView : NSOpenGLView {
|
||||
sf::priv::WindowImplCocoa* m_requester;
|
||||
BOOL m_useKeyRepeat;
|
||||
NSTrackingRectTag m_trackingTag;
|
||||
BOOL m_mouseIsIn;
|
||||
NSTrackingArea* m_trackingArea;
|
||||
NSSize m_realSize;
|
||||
|
||||
// Hidden text view used to convert key event to actual chars.
|
||||
|
@ -102,12 +102,14 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
[self enableKeyRepeat];
|
||||
m_realSize = NSZeroSize;
|
||||
|
||||
// Register for mouse-move event
|
||||
// Register for mouse move event
|
||||
m_mouseIsIn = [self isMouseInside];
|
||||
m_trackingTag = [self addTrackingRect:[self frame]
|
||||
owner:self
|
||||
userData:nil
|
||||
assumeInside:m_mouseIsIn];
|
||||
NSUInteger opts = (NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag);
|
||||
m_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||
options:opts
|
||||
owner:self
|
||||
userInfo:nil];
|
||||
[self addTrackingArea:m_trackingArea];
|
||||
|
||||
// Register for resize event
|
||||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
||||
@ -194,13 +196,6 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
// Update mouse internal state.
|
||||
[self updateMouseState];
|
||||
|
||||
// Adapt tracking area for mouse mouse event.
|
||||
[self removeTrackingRect:m_trackingTag];
|
||||
m_trackingTag = [self addTrackingRect:[self frame]
|
||||
owner:self
|
||||
userData:nil
|
||||
assumeInside:m_mouseIsIn];
|
||||
|
||||
// Update the OGL view to fit the new size.
|
||||
[self update];
|
||||
|
||||
@ -249,13 +244,16 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)dealloc
|
||||
{
|
||||
// Unregister
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[self removeTrackingArea:m_trackingArea];
|
||||
|
||||
// Release attributes
|
||||
[m_hiddenTextView release];
|
||||
[m_silentResponder release];
|
||||
[m_trackingArea release];
|
||||
|
||||
// Unregister
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[self removeTrackingRect:m_trackingTag];
|
||||
[self setRequesterTo:0];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user