Merge pull request #6139 from Abextm/input-fixes
Various ChatboxPanelManager fixes
This commit is contained in:
@@ -120,10 +120,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
public ChatboxTextInput value(String value)
|
public ChatboxTextInput value(String value)
|
||||||
{
|
{
|
||||||
this.value = new StringBuffer(value);
|
this.value = new StringBuffer(value);
|
||||||
if (built)
|
cursorAt(this.value.length());
|
||||||
{
|
|
||||||
clientThread.invoke(this::update);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,11 +280,13 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cursor.setTextColor(0xFFFFFF);
|
cursor.setTextColor(0xFFFFFF);
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
cursor.setOnTimerListener((JavaScriptCallback) ev ->
|
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.setOpacity(on ? 255 : 0);
|
||||||
});
|
});
|
||||||
|
cursor.setHasListener(true);
|
||||||
}
|
}
|
||||||
cursor.setFilled(true);
|
cursor.setFilled(true);
|
||||||
cursor.setOriginalX(mtx - 1);
|
cursor.setOriginalX(mtx - 1);
|
||||||
@@ -321,6 +320,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
isInBounds = ev -> bounds.contains(ev.getPoint());
|
isInBounds = ev -> bounds.contains(ev.getPoint());
|
||||||
getCharOffset = ev ->
|
getCharOffset = ev ->
|
||||||
{
|
{
|
||||||
|
if (fullWidth <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int cx = ev.getX() - canvasX;
|
int cx = ev.getX() - canvasX;
|
||||||
|
|
||||||
int charIndex = (tsValue.length() * cx) / fullWidth;
|
int charIndex = (tsValue.length() * cx) / fullWidth;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build()
|
public ChatboxTextMenuInput build()
|
||||||
{
|
{
|
||||||
if (title == null)
|
if (title == null)
|
||||||
{
|
{
|
||||||
@@ -100,6 +100,7 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
chatboxPanelManager.openInput(this);
|
chatboxPanelManager.openInput(this);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user