fix some bugs with text fields
This commit is contained in:
parent
95dc94d108
commit
3548b5806c
|
|
@ -140,9 +140,20 @@ public abstract class WDScreen extends Screen {
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
boolean clicked = false;
|
boolean clicked = false;
|
||||||
|
|
||||||
|
Control clickedEl = null;
|
||||||
for(Control ctrl: controls) {
|
for(Control ctrl: controls) {
|
||||||
clicked = ctrl.mouseClicked(mouseX, mouseY, button);
|
clicked = ctrl.mouseClicked(mouseX, mouseY, button);
|
||||||
if (clicked) break; // don't assume the compiler will optimize stuff
|
if (clicked) {
|
||||||
|
clickedEl = ctrl;
|
||||||
|
break; // don't assume the compiler will optimize stuff
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clicked) {
|
||||||
|
for (Control control : controls) {
|
||||||
|
if (control != clickedEl)
|
||||||
|
control.unfocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clicked;
|
return clicked;
|
||||||
|
|
|
||||||
|
|
@ -189,4 +189,10 @@ public abstract class Container extends BasicControl {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unfocus() {
|
||||||
|
for (Control control : childs) {
|
||||||
|
control.unfocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,9 @@ public abstract class Control {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unfocus() {
|
||||||
|
}
|
||||||
|
|
||||||
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,13 @@ public class ControlGroup extends Container {
|
||||||
height = bounds.getHeight() + paddingY * 2;
|
height = bounds.getHeight() + paddingY * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unfocus() {
|
||||||
|
for (Control control : childs) {
|
||||||
|
control.unfocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(JsonOWrapper json) {
|
public void load(JsonOWrapper json) {
|
||||||
super.load(json);
|
super.load(json);
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ public class List extends BasicControl {
|
||||||
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 1.f); //Set alpha to 1
|
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 1.f); //Set alpha to 1
|
||||||
RenderSystem.clearDepth(GL_COLOR_BUFFER_BIT);
|
RenderSystem.clearDepth(GL_COLOR_BUFFER_BIT);
|
||||||
fbo.unbindWrite();
|
fbo.unbindWrite();
|
||||||
|
mc.getMainRenderTarget().bindWrite(true);
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,8 +132,6 @@ public class List extends BasicControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.renderOutline(0, 0, width, height, 0xFF808080);
|
graphics.renderOutline(0, 0, width, height, 0xFF808080);
|
||||||
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 1.f); //Set alpha to 1
|
|
||||||
RenderSystem.clearDepth(GL_COLOR_BUFFER_BIT);
|
|
||||||
graphics.flush();
|
graphics.flush();
|
||||||
endFramebuffer(graphics, fbo);
|
endFramebuffer(graphics, fbo);
|
||||||
}
|
}
|
||||||
|
|
@ -321,10 +320,10 @@ public class List extends BasicControl {
|
||||||
@Override
|
@Override
|
||||||
public void draw(GuiGraphics graphics, int mouseX, int mouseY, float ptt) {
|
public void draw(GuiGraphics graphics, int mouseX, int mouseY, float ptt) {
|
||||||
if(visible) {
|
if(visible) {
|
||||||
// if(update) {
|
if(update) {
|
||||||
renderToFBO(graphics.bufferSource());
|
renderToFBO(graphics.bufferSource());
|
||||||
update = false;
|
update = false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
|
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
|
||||||
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
|
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
|
||||||
|
|
|
||||||
|
|
@ -99,15 +99,18 @@ public class TextField extends Control {
|
||||||
|
|
||||||
public TextField() {
|
public TextField() {
|
||||||
field = new EditBox(font, 1, 1, 198, 20, Component.nullToEmpty(""));
|
field = new EditBox(font, 1, 1, 198, 20, Component.nullToEmpty(""));
|
||||||
|
setFocused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextField(int x, int y, int width, int height) {
|
public TextField(int x, int y, int width, int height) {
|
||||||
field = new EditBox(font, x + 1, y + 1, width - 2, height - 2, Component.nullToEmpty(""));
|
field = new EditBox(font, x + 1, y + 1, width - 2, height - 2, Component.nullToEmpty(""));
|
||||||
|
setFocused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextField(int x, int y, int width, int height, String text) {
|
public TextField(int x, int y, int width, int height, String text) {
|
||||||
field = new EditBox(font, x + 1, y + 1, width - 2, height - 2, Component.nullToEmpty(""));
|
field = new EditBox(font, x + 1, y + 1, width - 2, height - 2, Component.nullToEmpty(""));
|
||||||
field.setValue(text);
|
field.setValue(text);
|
||||||
|
setFocused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make this public static in CefBrowserOSR
|
// TODO: make this public static in CefBrowserOSR
|
||||||
|
|
@ -166,11 +169,18 @@ public class TextField extends Control {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||||
if (field.mouseClicked(mouseX, mouseY, mouseButton))
|
if (field.mouseClicked(mouseX, mouseY, mouseButton)) {
|
||||||
setFocused(true);
|
setFocused(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unfocus() {
|
||||||
|
setFocused(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
||||||
return field.mouseReleased(mouseX, mouseY, state);
|
return field.mouseReleased(mouseX, mouseY, state);
|
||||||
|
|
@ -262,7 +272,8 @@ public class TextField extends Control {
|
||||||
|
|
||||||
public void setDisabled(boolean en) {
|
public void setDisabled(boolean en) {
|
||||||
enabled = !en;
|
enabled = !en;
|
||||||
field.setFocused(enabled);
|
if (!en)
|
||||||
|
field.setFocused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisabled() {
|
public boolean isDisabled() {
|
||||||
|
|
@ -270,7 +281,6 @@ public class TextField extends Control {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable() {
|
public void enable() {
|
||||||
field.setFocused(true);
|
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,7 +367,7 @@ public class TextField extends Control {
|
||||||
|
|
||||||
field.setTextColor(textColor);
|
field.setTextColor(textColor);
|
||||||
field.setTextColorUneditable(disabledColor);
|
field.setTextColorUneditable(disabledColor);
|
||||||
// field.setFocus(enabled);
|
setFocused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user