This commit is contained in:
xdrm-brackets 2017-12-12 14:04:34 +01:00
commit ee956629ea
1 changed files with 31 additions and 0 deletions

View File

@ -13,10 +13,16 @@ import Classes.css.user.SubMenuStyleSheet;
import Interfaces.Event;
import Interfaces.EventObserver;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;
@ -144,6 +150,31 @@ public class RootLayout extends Application implements EventObserver {
this.articles.clearContent();
TextField tx = new TextField();
tx.setPromptText("search...");
tx.setId("mag_searchbar");
tx.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent arg0) {
if(arg0.getCode() == KeyCode.ENTER) {
NewsListModel.getInstance().query(tx.textProperty().get());
}
}
});
Platform.runLater(new Runnable() {
@Override
public void run() {
RootLayout.this.main_container.getChildren().add(tx);
}
});
// For each news
for( NewsModel news : NewsListModel.getInstance().getNews() ){