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:
@@ -138,6 +138,8 @@ public :
|
|||||||
|
|
||||||
virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
|
virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
|
||||||
virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
|
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
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
|
@@ -462,11 +462,8 @@ bool g_lastButtonWasFakeRight = false ;
|
|||||||
- (CGFloat)scrollingDeltaY;
|
- (CGFloat)scrollingDeltaY;
|
||||||
@end
|
@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];
|
NSPoint locationInWindow = [nsEvent locationInWindow];
|
||||||
|
|
||||||
// adjust coordinates for the window of the target view
|
// 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];
|
NSPoint locationInView = [m_osxView convertPoint:locationInWindow fromView:nil];
|
||||||
wxPoint locationInViewWX = wxFromNSPoint( m_osxView, locationInView );
|
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
|
// these parameters are not given for all events
|
||||||
UInt32 button = [nsEvent buttonNumber];
|
UInt32 button = [nsEvent buttonNumber];
|
||||||
UInt32 clickCount = 0;
|
UInt32 clickCount = 0;
|
||||||
|
|
||||||
wxevent.m_x = locationInViewWX.x;
|
|
||||||
wxevent.m_y = locationInViewWX.y;
|
|
||||||
wxevent.m_shiftDown = modifiers & NSShiftKeyMask;
|
wxevent.m_shiftDown = modifiers & NSShiftKeyMask;
|
||||||
wxevent.m_rawControlDown = modifiers & NSControlKeyMask;
|
wxevent.m_rawControlDown = modifiers & NSControlKeyMask;
|
||||||
wxevent.m_altDown = modifiers & NSAlternateKeyMask;
|
wxevent.m_altDown = modifiers & NSAlternateKeyMask;
|
||||||
@@ -1176,19 +1183,39 @@ void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
|
|||||||
|
|
||||||
void wxWidgetCocoaImpl::cursorUpdate(WX_NSEvent event, WXWidget slf, void *_cmd)
|
void wxWidgetCocoaImpl::cursorUpdate(WX_NSEvent event, WXWidget slf, void *_cmd)
|
||||||
{
|
{
|
||||||
NSCursor *cursor = (NSCursor*)GetWXPeer()->GetCursor().GetHCURSOR();
|
if ( !SetupCursor(event) )
|
||||||
if (cursor == NULL)
|
|
||||||
{
|
{
|
||||||
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
||||||
superimpl(slf, (SEL)_cmd, event);
|
superimpl(slf, (SEL)_cmd, event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxWidgetCocoaImpl::SetupCursor(WX_NSEvent event)
|
||||||
|
{
|
||||||
|
extern wxCursor gGlobalCursor;
|
||||||
|
|
||||||
|
if ( gGlobalCursor.IsOk() )
|
||||||
|
{
|
||||||
|
gGlobalCursor.MacInstall();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
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)
|
void wxWidgetCocoaImpl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
|
||||||
{
|
{
|
||||||
@@ -2539,7 +2566,11 @@ bool wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent *event)
|
|||||||
{
|
{
|
||||||
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
||||||
SetupMouseEvent(wxevent , event) ;
|
SetupMouseEvent(wxevent , event) ;
|
||||||
return GetWXPeer()->HandleWindowEvent(wxevent);
|
bool result = GetWXPeer()->HandleWindowEvent(wxevent);
|
||||||
|
|
||||||
|
(void)SetupCursor(event);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow)
|
void wxWidgetCocoaImpl::DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow)
|
||||||
@@ -2656,11 +2687,13 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
|||||||
{
|
{
|
||||||
NSView* cv = [tlw contentView];
|
NSView* cv = [tlw contentView];
|
||||||
c = new wxWidgetCocoaImpl( now, cv, true );
|
c = new wxWidgetCocoaImpl( now, cv, true );
|
||||||
|
if ( cv != nil )
|
||||||
|
{
|
||||||
// increase ref count, because the impl destructor will decrement it again
|
// increase ref count, because the impl destructor will decrement it again
|
||||||
CFRetain(cv);
|
CFRetain(cv);
|
||||||
if ( !now->IsShown() )
|
if ( !now->IsShown() )
|
||||||
[cv setHidden:NO];
|
[cv setHidden:NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user