ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
TextInputGate.h
浏览该文件的文档.
1
#pragma once
2
#include "
../Core/Core.h
"
3
#include "
../Input/KeyCode.h
"
4
5
#include <unordered_set>
6
7
union
SDL_Event;
8
struct
SDL_Rect;
9
10
namespace
Shit
{
11
class
UITextInput
;
12
24
class
SHIT_API
TextInputGate
final {
25
public
:
26
TextInputGate
(
const
TextInputGate
&) =
delete
;
27
TextInputGate
&
operator=
(
const
TextInputGate
&) =
delete
;
28
29
static
TextInputGate
&
GetInstance
();
30
33
static
bool
HandleEvent
(
const
SDL_Event& event) {
return
GetInstance
().handleEvent(event); }
34
36
static
bool
HasFocus
();
37
39
void
requestFocus
(
UITextInput
* control);
40
42
void
releaseFocus
(
UITextInput
* control);
43
45
void
clearFocus
();
46
48
void
updateCursorRect
(
const
SDL_Rect& rect,
int
cursor);
49
50
private
:
51
friend
class
EngineContext
;
52
TextInputGate
() =
default
;
53
~TextInputGate
() =
default
;
54
55
bool
handleEvent(
const
SDL_Event& event);
56
57
UITextInput
* m_focused =
nullptr
;
58
61
std::unordered_set<KeyCode> m_focusConsumedKeys;
62
};
63
}
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:14
KeyCode.h
Shit::TextInputGate::updateCursorRect
void updateCursorRect(const SDL_Rect &rect, int cursor)
通知 IME 光标位置变化(用窗口坐标的 SDL_Rect)
Shit::TextInputGate::requestFocus
void requestFocus(UITextInput *control)
请求聚焦某控件:失焦当前控件,启动新控件的文本输入模式
Shit::TextInputGate::TextInputGate
TextInputGate(const TextInputGate &)=delete
Shit::TextInputGate::HandleEvent
static bool HandleEvent(const SDL_Event &event)
获取原生事件转发入口(由 Game 在 PollEvent 后调用)
定义
TextInputGate.h:33
Shit::TextInputGate::clearFocus
void clearFocus()
强制清空焦点(例如场景销毁时)
Shit::TextInputGate::operator=
TextInputGate & operator=(const TextInputGate &)=delete
Shit::TextInputGate::GetInstance
static TextInputGate & GetInstance()
Shit::TextInputGate::EngineContext
friend class EngineContext
定义
TextInputGate.h:51
Shit::TextInputGate::releaseFocus
void releaseFocus(UITextInput *control)
失焦指定控件(仅当它当前正在聚焦时才生效)
Shit::TextInputGate::HasFocus
static bool HasFocus()
当前是否有聚焦控件
Shit::UITextInput
文本输入控件抽象基类
定义
UITextInput.h:25
Shit
定义
AudioPlayer.h:10
include
ShitEngine
Core
TextInputGate.h
制作者
1.17.0