Remove tooltip tracking code from wxOSX
This doesn't seem to be necessary and is actually actively harmful, as this code prevented tooltips from working with non-native windows, such as those used inside wxSplitterWindow in the splitter sample. Just remove this code entirely and add SetToolTip() calls to the sample to show that they do work now. Closes https://github.com/wxWidgets/wxWidgets/pull/1978 Closes #14220.
This commit is contained in:
parent
717e6590bd
commit
ce4cb33c20
2 changed files with 2 additions and 82 deletions
|
|
@ -292,9 +292,11 @@ MyFrame::MyFrame()
|
|||
m_left = new MyCanvas(m_splitter, true);
|
||||
m_left->SetBackgroundColour(*wxRED);
|
||||
m_left->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
|
||||
m_left->SetToolTip("This is the left window");
|
||||
|
||||
m_right = new MyCanvas(m_splitter, false);
|
||||
m_right->SetBackgroundColour(*wxCYAN);
|
||||
m_right->SetToolTip("And this is the window on the right");
|
||||
#else // for testing kbd navigation inside the splitter
|
||||
m_left = new wxTextCtrl(m_splitter, wxID_ANY, "first text");
|
||||
m_right = new wxTextCtrl(m_splitter, wxID_ANY, "second text");
|
||||
|
|
|
|||
|
|
@ -153,11 +153,6 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
|
|||
|
||||
@interface wxNSView : NSView
|
||||
{
|
||||
BOOL _hasToolTip;
|
||||
NSTrackingRectTag _lastToolTipTrackTag;
|
||||
id _lastToolTipOwner;
|
||||
void* _lastUserData;
|
||||
|
||||
}
|
||||
|
||||
@end // wxNSView
|
||||
|
|
@ -847,83 +842,6 @@ static void SetDrawingEnabledIfFrozenRecursive(wxWidgetCocoaImpl *impl, bool ena
|
|||
*/
|
||||
|
||||
|
||||
- (void)_sendToolTipMouseExited
|
||||
{
|
||||
// Nothing matters except window, trackingNumber, and userData.
|
||||
NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:0
|
||||
timestamp:0
|
||||
windowNumber:[[self window] windowNumber]
|
||||
context:NULL
|
||||
eventNumber:0
|
||||
trackingNumber:_lastToolTipTrackTag
|
||||
userData:_lastUserData];
|
||||
[_lastToolTipOwner mouseExited:fakeEvent];
|
||||
}
|
||||
|
||||
- (void)_sendToolTipMouseEntered
|
||||
{
|
||||
// Nothing matters except window, trackingNumber, and userData.
|
||||
NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:0
|
||||
timestamp:0
|
||||
windowNumber:[[self window] windowNumber]
|
||||
context:NULL
|
||||
eventNumber:0
|
||||
trackingNumber:_lastToolTipTrackTag
|
||||
userData:_lastUserData];
|
||||
[_lastToolTipOwner mouseEntered:fakeEvent];
|
||||
}
|
||||
|
||||
- (void)setToolTip:(NSString *)string
|
||||
{
|
||||
if (string)
|
||||
{
|
||||
if ( _hasToolTip )
|
||||
{
|
||||
[self _sendToolTipMouseExited];
|
||||
}
|
||||
|
||||
[super setToolTip:string];
|
||||
_hasToolTip = YES;
|
||||
[self _sendToolTipMouseEntered];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( _hasToolTip )
|
||||
{
|
||||
[self _sendToolTipMouseExited];
|
||||
[super setToolTip:nil];
|
||||
_hasToolTip = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSTrackingRectTag)addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside
|
||||
{
|
||||
NSTrackingRectTag tag = [super addTrackingRect:rect owner:owner userData:data assumeInside:assumeInside];
|
||||
if ( owner != self )
|
||||
{
|
||||
_lastUserData = data;
|
||||
_lastToolTipOwner = owner;
|
||||
_lastToolTipTrackTag = tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
- (void)removeTrackingRect:(NSTrackingRectTag)tag
|
||||
{
|
||||
if (tag == _lastToolTipTrackTag)
|
||||
{
|
||||
_lastUserData = NULL;
|
||||
_lastToolTipOwner = nil;
|
||||
_lastToolTipTrackTag = 0;
|
||||
}
|
||||
[super removeTrackingRect:tag];
|
||||
}
|
||||
|
||||
#if wxOSX_USE_NATIVE_FLIPPED
|
||||
- (BOOL)isFlipped
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue