made chat history always scroll to the bottom after a message is sent #story[1246]

This commit is contained in:
Peter Galloway
2017-08-31 16:35:51 +12:00
parent 0fcdf41419
commit 24d4c1df15
@@ -11,6 +11,8 @@ import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
@@ -123,6 +125,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
chatInput.setText(chatInput.getText().substring(0, CHAT_LIMIT));
}
});
chatHistory.textProperty().addListener((obs, oldValue, newValue) -> {
chatHistory.setScrollTop(Double.MAX_VALUE);
});
}
public void loadRace (
@@ -657,7 +662,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
}
public void updateChatHistory(Paint playerColour, String newMessage) {
chatHistory.setText(chatHistory.getText() + newMessage + '\n');
chatHistory.appendText(newMessage + '\n');
}
}