Files
XCEngine/docs/api/XCEngine/Input/InputManager/IsMouseButtonClicked.md

32 lines
624 B
Markdown
Raw Normal View History

2026-03-26 16:45:24 +08:00
# InputManager::IsMouseButtonClicked
2026-03-26 17:39:53 +08:00
查询鼠标按键是否在本帧刚被按下。
2026-03-26 16:45:24 +08:00
```cpp
bool IsMouseButtonClicked(MouseButton button) const;
```
2026-03-26 17:39:53 +08:00
## 行为说明
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
当前实现与 `IsKeyPressed` 类似,判断条件是:
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
```cpp
m_mouseButtonDownThisFrame[index] && !m_mouseButtonDownLastFrame[index]
```
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
它表示的是“本帧按下边沿”,而不是完整的点击手势。
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
## 参数
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
- `button` - 要查询的鼠标按键。
## 返回值
- `bool` - 当前帧是否刚被按下。
2026-03-26 16:45:24 +08:00
## 相关文档
2026-03-26 17:39:53 +08:00
- [返回类型总览](InputManager.md)
- [IsMouseButtonDown](IsMouseButtonDown.md)
- [Update](Update.md)