TextInputManager.java
com.mojang.blaze3d.platform.TextInputManager
信息
- 全限定名:com.mojang.blaze3d.platform.TextInputManager
- 类型:public class
- 包:com.mojang.blaze3d.platform
- 源码路径:src/main/java/com/mojang/blaze3d/platform/TextInputManager.java
- 起始行号:L8
- 职责:
TODO
字段/常量
-
window- 类型:
Window - 修饰符:
private final - 源码定位:
L9 - 说明:
TODO
- 类型:
-
textInputEnabled- 类型:
boolean - 修饰符:
private - 源码定位:
L10 - 说明:
TODO
- 类型:
-
imeRequested- 类型:
boolean - 修饰符:
private - 源码定位:
L11 - 说明:
TODO
- 类型:
-
imeStatusChanged- 类型:
boolean - 修饰符:
private volatile - 源码定位:
L12 - 说明:
TODO
- 类型:
-
cachedIMEStatus- 类型:
boolean - 修饰符:
private - 源码定位:
L13 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public TextInputManager(Window window) @ L15
- 构造器名:TextInputManager
- 源码定位:L15
- 修饰符:public
参数:
- window: Window
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void setTextInputArea(int x0, int y0, int x1, int y1) @ L19
- 方法名:setTextInputArea
- 源码定位:L19
- 返回类型:void
- 修饰符:public
参数:
- x0: int
- y0: int
- x1: int
- y1: int
说明:
TODO
public void notifyIMEChanged() @ L24
- 方法名:notifyIMEChanged
- 源码定位:L24
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void tick() @ L28
- 方法名:tick
- 源码定位:L28
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private boolean getIMEStatus() @ L36
- 方法名:getIMEStatus
- 源码定位:L36
- 返回类型:boolean
- 修饰符:private
参数:
- 无
说明:
TODO
private void tickOutsideTextInput() @ L45
- 方法名:tickOutsideTextInput
- 源码定位:L45
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
private void tickDuringTextInput() @ L51
- 方法名:tickDuringTextInput
- 源码定位:L51
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
public void startTextInput() @ L55
- 方法名:startTextInput
- 源码定位:L55
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void stopTextInput() @ L62
- 方法名:stopTextInput
- 源码定位:L62
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void onTextInputFocusChange(boolean focused) @ L66
- 方法名:onTextInputFocusChange
- 源码定位:L66
- 返回类型:void
- 修饰符:public
参数:
- focused: boolean
说明:
TODO
private void setIMEInputMode(boolean value) @ L74
- 方法名:setIMEInputMode
- 源码定位:L74
- 返回类型:void
- 修饰符:private
参数:
- value: boolean
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TextInputManager {
private final Window window;
private boolean textInputEnabled;
private boolean imeRequested;
private volatile boolean imeStatusChanged = true;
private boolean cachedIMEStatus;
public TextInputManager(Window window) {
this.window = window;
}
public void setTextInputArea(int x0, int y0, int x1, int y1) {
int guiScale = this.window.getGuiScale();
GLFW.glfwSetPreeditCursorRectangle(this.window.handle(), x0 * guiScale, y0 * guiScale, (x1 - x0) * guiScale, (y1 - y0) * guiScale);
}
public void notifyIMEChanged() {
this.imeStatusChanged = true;
}
public void tick() {
if (this.textInputEnabled) {
this.tickDuringTextInput();
} else {
this.tickOutsideTextInput();
}
}
private boolean getIMEStatus() {
if (this.imeStatusChanged) {
this.imeStatusChanged = false;
this.cachedIMEStatus = GLFW.glfwGetInputMode(this.window.handle(), 208903) == 1;
}
return this.cachedIMEStatus;
}
private void tickOutsideTextInput() {
if (this.window.isFocused() && this.getIMEStatus()) {
this.setIMEInputMode(false);
}
}
private void tickDuringTextInput() {
this.imeRequested = this.getIMEStatus();
}
public void startTextInput() {
this.textInputEnabled = true;
if (this.imeRequested) {
this.setIMEInputMode(true);
}
}
public void stopTextInput() {
this.textInputEnabled = false;
}
public void onTextInputFocusChange(boolean focused) {
if (focused) {
this.startTextInput();
} else {
this.stopTextInput();
}
}
private void setIMEInputMode(boolean value) {
GLFW.glfwSetInputMode(this.window.handle(), 208903, GLX.glfwBool(value));
}
}