【发布时间】:2022-11-11 23:05:03
【问题描述】:
我有一种感觉,这是苹果的另一个“魔法”,
但我无法检测到非常简单和基本的事件:
当用户停止使用鼠标滚轮滚动时(-end- 事件)
- (void)scrollWheel:(NSEvent *)event
{
[super scrollWheel:event];
//// NSEventPhaseNone = 0, // event not associated with a phase.
//// NSEventPhaseBegan = 0x1 << 0,
//// NSEventPhaseStationary = 0x1 << 1,
//// NSEventPhaseChanged = 0x1 << 2,
//// NSEventPhaseEnded = 0x1 << 3,
//// NSEventPhaseCancelled = 0x1 << 4,
//// NSEventPhaseMayBegin = 0x1 << 5,
///
///
//event.phase -always- 0
//event.momentumPhase -always- 0
NSLog(@"event.momentumPhase = %lu, event.phase = %lu", (unsigned long)event.momentumPhase, event.phase);
if(event.phase & NSEventPhaseBegan)
{
// never called when user start scrolling with mouse wheel
NSLog(@"NSEventPhaseBegan");
}
if(event.phase & NSEventPhaseEnded)
{
// never called when user end scrolling with mouse wheel
NSLog(@"NSEventPhaseEnded");
}
}
我检查了 NSEvent 的所有属性,但没有要检查的数据。 谷歌搜索以检查其他人在做什么。没有什么能真正解决这个问题。 一些解决方案是这样的,但是......这总是返回 0。
【问题讨论】:
-
据我所知,没有鼠标滚轮结束事件,就像没有鼠标停止移动事件或用户停止打字事件一样。
NSEvent.phase与手势一起使用。 -
但是有“用户停止滚动事件”(用鼠标移动滚动条时)。问题是如果用户使用鼠标滚轮滚动我也无法检测到它。所以没有它就没用了。
-
滚动条检测到鼠标向上事件。应该如何检测到滚轮结束事件?
标签: cocoa appkit nsscrollview