mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +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,14 +244,17 @@ 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];
|
||||
|
||||
[self setRequesterTo:0];
|
||||
|
||||
// Unregister
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[self removeTrackingRect:m_trackingTag];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user