Merge pull request #6139 from Abextm/input-fixes

Various ChatboxPanelManager fixes
This commit is contained in:
Abex
2018-10-24 01:45:51 -06:00
committed by GitHub
2 changed files with 11 additions and 6 deletions

View File

@@ -120,10 +120,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
public ChatboxTextInput value(String value)
{
this.value = new StringBuffer(value);
if (built)
{
clientThread.invoke(this::update);
}
cursorAt(this.value.length());
return this;
}
@@ -283,11 +280,13 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
else
{
cursor.setTextColor(0xFFFFFF);
long start = System.currentTimeMillis();
cursor.setOnTimerListener((JavaScriptCallback) ev ->
{
boolean on = System.currentTimeMillis() % CURSOR_FLASH_RATE_MILLIS > (CURSOR_FLASH_RATE_MILLIS / 2);
boolean on = (System.currentTimeMillis() - start) % CURSOR_FLASH_RATE_MILLIS > (CURSOR_FLASH_RATE_MILLIS / 2);
cursor.setOpacity(on ? 255 : 0);
});
cursor.setHasListener(true);
}
cursor.setFilled(true);
cursor.setOriginalX(mtx - 1);
@@ -321,6 +320,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
isInBounds = ev -> bounds.contains(ev.getPoint());
getCharOffset = ev ->
{
if (fullWidth <= 0)
{
return 0;
}
int cx = ev.getX() - canvasX;
int charIndex = (tsValue.length() * cx) / fullWidth;

View File

@@ -87,7 +87,7 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
return this;
}
public void build()
public ChatboxTextMenuInput build()
{
if (title == null)
{
@@ -100,6 +100,7 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
}
chatboxPanelManager.openInput(this);
return this;
}
@Override