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) {
|
||||
boolean clicked = false;
|
||||
|
||||
Control clickedEl = null;
|
||||
for(Control ctrl: controls) {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -189,4 +189,10 @@ public abstract class Container extends BasicControl {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unfocus() {
|
||||
for (Control control : childs) {
|
||||
control.unfocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ public abstract class Control {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void unfocus() {
|
||||
}
|
||||
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,6 +184,13 @@ public class ControlGroup extends Container {
|
|||
height = bounds.getHeight() + paddingY * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unfocus() {
|
||||
for (Control control : childs) {
|
||||
control.unfocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(JsonOWrapper 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.clearDepth(GL_COLOR_BUFFER_BIT);
|
||||
fbo.unbindWrite();
|
||||
mc.getMainRenderTarget().bindWrite(true);
|
||||
update = true;
|
||||
}
|
||||
|
||||
|
|
@ -131,8 +132,6 @@ public class List extends BasicControl {
|
|||
}
|
||||
|
||||
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();
|
||||
endFramebuffer(graphics, fbo);
|
||||
}
|
||||
|
|
@ -321,10 +320,10 @@ public class List extends BasicControl {
|
|||
@Override
|
||||
public void draw(GuiGraphics graphics, int mouseX, int mouseY, float ptt) {
|
||||
if(visible) {
|
||||
// if(update) {
|
||||
if(update) {
|
||||
renderToFBO(graphics.bufferSource());
|
||||
update = false;
|
||||
// }
|
||||
}
|
||||
|
||||
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
|
||||
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
|
||||
|
|
|
|||
|
|
@ -99,15 +99,18 @@ public class TextField extends Control {
|
|||
|
||||
public TextField() {
|
||||
field = new EditBox(font, 1, 1, 198, 20, Component.nullToEmpty(""));
|
||||
setFocused(false);
|
||||
}
|
||||
|
||||
public TextField(int x, int y, int width, int height) {
|
||||
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) {
|
||||
field = new EditBox(font, x + 1, y + 1, width - 2, height - 2, Component.nullToEmpty(""));
|
||||
field.setValue(text);
|
||||
setFocused(false);
|
||||
}
|
||||
|
||||
// TODO: make this public static in CefBrowserOSR
|
||||
|
|
@ -166,11 +169,18 @@ public class TextField extends Control {
|
|||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||
if (field.mouseClicked(mouseX, mouseY, mouseButton))
|
||||
if (field.mouseClicked(mouseX, mouseY, mouseButton)) {
|
||||
setFocused(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unfocus() {
|
||||
setFocused(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
||||
return field.mouseReleased(mouseX, mouseY, state);
|
||||
|
|
@ -262,7 +272,8 @@ public class TextField extends Control {
|
|||
|
||||
public void setDisabled(boolean en) {
|
||||
enabled = !en;
|
||||
field.setFocused(enabled);
|
||||
if (!en)
|
||||
field.setFocused(false);
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
|
|
@ -270,7 +281,6 @@ public class TextField extends Control {
|
|||
}
|
||||
|
||||
public void enable() {
|
||||
field.setFocused(true);
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +367,7 @@ public class TextField extends Control {
|
|||
|
||||
field.setTextColor(textColor);
|
||||
field.setTextColorUneditable(disabledColor);
|
||||
// field.setFocus(enabled);
|
||||
setFocused(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user