未验证 提交 097891e3 编写于 作者: T thewoz 提交者: GitHub

Merge pull request #23394 from thewoz:Cocoa-Scroll-Wheel

Add scrollWheel to Cocoa #23394

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
上级 1af084cb
...@@ -504,7 +504,7 @@ left scrolling, respectively. ...@@ -504,7 +504,7 @@ left scrolling, respectively.
@note @note
Mouse-wheel events are currently supported only on Windows. Mouse-wheel events are currently supported only on Windows and Cocoa
@param flags The mouse callback flags parameter. @param flags The mouse callback flags parameter.
*/ */
......
...@@ -899,8 +899,22 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) { ...@@ -899,8 +899,22 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
mp.y *= (imageSize.height / std::max(viewSize.height, 1.)); mp.y *= (imageSize.height / std::max(viewSize.height, 1.));
mp.x *= (imageSize.width / std::max(viewSize.width, 1.)); mp.x *= (imageSize.width / std::max(viewSize.width, 1.));
if( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height ) if( [event type] == NSEventTypeScrollWheel ) {
mouseCallback(type, mp.x, mp.y, flags, mouseParam); if( event.hasPreciseScrollingDeltas ) {
mp.x = int(event.scrollingDeltaX);
mp.y = int(event.scrollingDeltaY);
} else {
mp.x = int(event.scrollingDeltaX / 0.100006);
mp.y = int(event.scrollingDeltaY / 0.100006);
}
if( mp.x && !mp.y && CV_EVENT_MOUSEWHEEL == type ) {
type = CV_EVENT_MOUSEHWHEEL;
}
mouseCallback(type, mp.x, mp.y, flags, mouseParam);
} else if( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height ) {
mouseCallback(type, mp.x, mp.y, flags, mouseParam);
}
} }
- (void)cvMouseEvent:(NSEvent *)event { - (void)cvMouseEvent:(NSEvent *)event {
...@@ -923,6 +937,11 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) { ...@@ -923,6 +937,11 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
if([event type] == NSLeftMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_LBUTTON];} if([event type] == NSLeftMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_LBUTTON];}
if([event type] == NSRightMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_RBUTTON];} if([event type] == NSRightMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_RBUTTON];}
if([event type] == NSOtherMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_MBUTTON];} if([event type] == NSOtherMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_MBUTTON];}
if([event type] == NSEventTypeScrollWheel) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEWHEEL flags:flags ];}
}
-(void)scrollWheel:(NSEvent *)theEvent {
[self cvMouseEvent:theEvent];
} }
- (void)keyDown:(NSEvent *)theEvent { - (void)keyDown:(NSEvent *)theEvent {
//cout << "keyDown" << endl; //cout << "keyDown" << endl;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册