avoid deprecated API, fixes #13727

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2012-07-24 09:14:51 +00:00
parent 6abe329feb
commit 28a62eec09

View File

@ -455,6 +455,11 @@ bool g_lastButtonWasFakeRight = false ;
@interface NSEvent (DeviceDelta)
- (CGFloat)deviceDeltaX;
- (CGFloat)deviceDeltaY;
// 10.7+
- (BOOL)hasPreciseScrollingDeltas;
- (CGFloat)scrollingDeltaX;
- (CGFloat)scrollingDeltaY;
@end
void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
@ -609,23 +614,39 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
// see http://developer.apple.com/qa/qa2005/qa1453.html
// for more details on why we have to look for the exact type
const EventRef cEvent = (EventRef) [nsEvent eventRef];
bool isMouseScrollEvent = false;
if ( cEvent )
isMouseScrollEvent = ::GetEventKind(cEvent) == kEventMouseScroll;
if ( isMouseScrollEvent )
if ( UMAGetSystemVersion() >= 0x1070 )
{
deltaX = [nsEvent deviceDeltaX];
deltaY = [nsEvent deviceDeltaY];
if ( [nsEvent hasPreciseScrollingDeltas] )
{
deltaX = [nsEvent scrollingDeltaX];
deltaY = [nsEvent scrollingDeltaY];
}
else
{
deltaX = [nsEvent scrollingDeltaX] * 10;
deltaY = [nsEvent scrollingDeltaY] * 10;
}
}
else
{
deltaX = ([nsEvent deltaX] * 10);
deltaY = ([nsEvent deltaY] * 10);
const EventRef cEvent = (EventRef) [nsEvent eventRef];
// see http://developer.apple.com/qa/qa2005/qa1453.html
// for more details on why we have to look for the exact type
bool isMouseScrollEvent = false;
if ( cEvent )
isMouseScrollEvent = ::GetEventKind(cEvent) == kEventMouseScroll;
if ( isMouseScrollEvent )
{
deltaX = [nsEvent deviceDeltaX];
deltaY = [nsEvent deviceDeltaY];
}
else
{
deltaX = ([nsEvent deltaX] * 10);
deltaY = ([nsEvent deltaY] * 10);
}
}
wxevent.m_wheelDelta = 10;