Je travaille avec un projet multi-vues avec FXML, généré par le plugin Gluon pour IntelliJ.Gluon mobile Problème de clavier logiciel TextArea
J'ai ajouté une vue (vue d'analyse) à côté de la vue primaire et secondaire générée et le code fourni pour la navigation dans la classe GluonApplication.
La première fois que je navigue vers la vue de balayage, un carret clignote dans la zone de texte mais le clavier virtuel de mon appareil Android n'est pas affiché. Lorsque je navigue vers une autre vue, le clavier s'affiche brièvement et disparaît après une seconde. Ensuite, lorsque je reviens à la vue de balayage, le clavier virtuel s'affiche. Et enfin, quand je retire le focus de la zone de texte avec le bouton de retour sur mon appareil Android, il n'est pas possible de retrouver le focus en appuyant sur la zone de texte.
Toute information bienvenue, à votre santé.
GluonApplication.java:
public class GluonApplication extends MobileApplication {
public static final String PRIMARY_VIEW = HOME_VIEW;
public static final String SECONDARY_VIEW = "Product View";
public static final String SCAN_VIEW = "Scan View";
public static final String MENU_LAYER = "Side Menu";
@Override
public void init() {
//Add views.
addViewFactory(PRIMARY_VIEW,() -> (View) new PicklistView().getView());
addViewFactory(SECONDARY_VIEW,() -> (View) new ProductView().getView());
addViewFactory(SCAN_VIEW,() -> (View) new ScanView().getView());
//Navigation side bar configuration.
NavigationDrawer drawer = new NavigationDrawer();
NavigationDrawer.Header header = new NavigationDrawer.Header("Gluon Mobile",
"Multi View Project",
new Avatar(21, new Image(GluonApplication.class.getResourceAsStream("/icon.png"))));
drawer.setHeader(header);
final Item primaryItem = new Item("Picklist", MaterialDesignIcon.HOME.graphic());
final Item secondaryItem = new Item("Product", MaterialDesignIcon.DASHBOARD.graphic());
final Item scanItem = new Item("Scan", MaterialDesignIcon.DASHBOARD.graphic());
drawer.getItems().addAll(primaryItem, secondaryItem, scanItem);
drawer.selectedItemProperty().addListener((obs, oldItem, newItem) -> {
hideLayer(MENU_LAYER);
if (newItem.equals(primaryItem)) {
switchView(PRIMARY_VIEW);
} else if (newItem.equals(secondaryItem)) {
switchView(SECONDARY_VIEW);
} else {
switchView(SCAN_VIEW);
}
});
addLayerFactory(MENU_LAYER,() -> new SidePopupView(drawer));
}
scan.fxml:
<?import com.gluonhq.charm.glisten.mvc.View?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<View fx:id="scan" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="350.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.essers.pxl2016.scan.views.ScanPresenter">
<center>
<VBox alignment="TOP_CENTER" BorderPane.alignment="CENTER">
<children>
<Label fx:id="label" text="scan output label">
<VBox.margin>
<Insets bottom="5.0" />
</VBox.margin></Label>
<TextArea fx:id="input" />
</children>
</VBox>
</center>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</View>
ScanPresenter:
public class ScanPresenter {
@FXML
private View scan;
@FXML
private Label label;
@FXML
private TextArea input;
private String oldString;
public void initialize() {
scan.showingProperty().addListener((obs, oldValue, newValue) -> {
// Update app bar.
if (newValue) {
AppBar appBar = MobileApplication.getInstance().getAppBar();
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e ->
MobileApplication.getInstance().showLayer(GluonApplication.MENU_LAYER)));
appBar.setTitleText("Scan");
appBar.getActionItems().add(MaterialDesignIcon.CLOSE.button(e ->
javafx.application.Platform.exit()));
}
});
input.textProperty().addListener((observable, oldValue, newValue) -> {
if (oldValue.equals(newValue)) {
return;
} else {
label.setText(newValue);
}
});
input.requestFocus();
}
}