enabling cursor events, fixes #15044

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2013-03-02 13:01:57 +00:00
parent 23c37c2c4e
commit 094fa9e9ef
2 changed files with 56 additions and 21 deletions

View File

@@ -138,6 +138,8 @@ public :
virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
void SetupCoordinates(wxCoord &x, wxCoord &y, NSEvent *nsEvent);
virtual bool SetupCursor(NSEvent* event);
#if !wxOSX_USE_NATIVE_FLIPPED

View File

@@ -462,11 +462,8 @@ bool g_lastButtonWasFakeRight = false ;
- (CGFloat)scrollingDeltaY;
@end
void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
void wxWidgetCocoaImpl::SetupCoordinates(wxCoord &x, wxCoord &y, NSEvent* nsEvent)
{
int eventType = [nsEvent type];
UInt32 modifiers = [nsEvent modifierFlags] ;
NSPoint locationInWindow = [nsEvent locationInWindow];
// adjust coordinates for the window of the target view
@@ -482,12 +479,22 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
NSPoint locationInView = [m_osxView convertPoint:locationInWindow fromView:nil];
wxPoint locationInViewWX = wxFromNSPoint( m_osxView, locationInView );
x = locationInViewWX.x;
y = locationInViewWX.y;
}
void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
{
int eventType = [nsEvent type];
UInt32 modifiers = [nsEvent modifierFlags] ;
SetupCoordinates(wxevent.m_x, wxevent.m_y, nsEvent);
// these parameters are not given for all events
UInt32 button = [nsEvent buttonNumber];
UInt32 clickCount = 0;
wxevent.m_x = locationInViewWX.x;
wxevent.m_y = locationInViewWX.y;
wxevent.m_shiftDown = modifiers & NSShiftKeyMask;
wxevent.m_rawControlDown = modifiers & NSControlKeyMask;
wxevent.m_altDown = modifiers & NSAlternateKeyMask;
@@ -1176,20 +1183,40 @@ void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
void wxWidgetCocoaImpl::cursorUpdate(WX_NSEvent event, WXWidget slf, void *_cmd)
{
NSCursor *cursor = (NSCursor*)GetWXPeer()->GetCursor().GetHCURSOR();
if (cursor == NULL)
if ( !SetupCursor(event) )
{
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
superimpl(slf, (SEL)_cmd, event);
}
}
bool wxWidgetCocoaImpl::SetupCursor(WX_NSEvent event)
{
extern wxCursor gGlobalCursor;
if ( gGlobalCursor.IsOk() )
{
gGlobalCursor.MacInstall();
return true;
}
else
{
[cursor set];
wxWindow* cursorTarget = GetWXPeer();
wxCoord x,y;
SetupCoordinates(x, y, event);
wxPoint cursorPoint( x , y ) ;
while ( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
{
cursorTarget = cursorTarget->GetParent() ;
if ( cursorTarget )
cursorPoint += cursorTarget->GetPosition();
}
return cursorTarget != NULL;
}
}
void wxWidgetCocoaImpl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
{
if ( [event type] == NSKeyDown )
@@ -2539,7 +2566,11 @@ bool wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent *event)
{
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
SetupMouseEvent(wxevent , event) ;
return GetWXPeer()->HandleWindowEvent(wxevent);
bool result = GetWXPeer()->HandleWindowEvent(wxevent);
(void)SetupCursor(event);
return result;
}
void wxWidgetCocoaImpl::DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow)
@@ -2656,11 +2687,13 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
{
NSView* cv = [tlw contentView];
c = new wxWidgetCocoaImpl( now, cv, true );
if ( cv != nil )
{
// increase ref count, because the impl destructor will decrement it again
CFRetain(cv);
if ( !now->IsShown() )
[cv setHidden:NO];
}
}
else
{