Add tagForLayerContainingPoint:

This is meant for subclasses which need to translate an NSPoint to a layer and cannot rely on the normal handling of this in the superclass.
This commit is contained in:
Allan Odgaard
2012-08-25 17:41:09 +02:00
parent 1c9640f00b
commit 81eda77ee2
2 changed files with 12 additions and 0 deletions

View File

@@ -90,6 +90,7 @@ struct layer_t
- (uint32_t)currentState;
- (void)setLayout:(std::vector<layer_t> const&)aLayout;
- (void)sendAction:(SEL)action fromLayer:(layer_t const&)aLayer;
- (NSInteger)tagForLayerContainingPoint:(NSPoint)aPoint;
@property (nonatomic, readonly) NSInteger tag; // tag of the most recent layer causing an action
@property (nonatomic, assign) BOOL mouseTrackingDisabled;
@end

View File

@@ -126,6 +126,17 @@ OAK_DEBUG_VAR(OakControl);
return YES;
}
- (NSInteger)tagForLayerContainingPoint:(NSPoint)aPoint
{
NSInteger res = NSNotFound;
iterate(it, layout)
{
if(NSMouseInRect(aPoint, it->rect, [self isFlipped]))
res = it->tag;
}
return res;
}
- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent*)event
{
// This code is copy/paste from mouseDown: and should ideally be de-duplicated.