2016-03-25 55 views
0

我正在使用FXML的多視圖項目,由IntelliJ的Gluon插件生成。Gluon mobile TextArea軟鍵盤問題

我在生成的主視圖和次視圖旁邊添加了一個視圖(掃描視圖),並在GluonApplication類中提供了導航代碼。

我第一次導航到掃描視圖時,一個carret在textarea中閃爍,但我的android設備上的軟鍵盤未顯示。 當我導航到另一個視圖時,鍵盤會短暫顯示自身並在一秒鐘後消失。 然後,當我導航回掃描視圖時,軟鍵盤顯示。 最後,當我用我的android設備上的後退按鈕從textarea撤回焦點時,通過點擊textarea無法重新獲得焦點。

歡迎任何信息,歡呼聲。

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(); 
    } 
} 

回答

1

這是一個已知的問題,但現在看來,這只是固定TextFields:https://bitbucket.org/javafxports/8u-dev-rt/commits/ef07043d5739ace78568f20d7bc89ba0cf60c4e0

我剛剛創建了一個拉請求將解決這個問題的文本區域,以及:計劃某處下週創建https://bitbucket.org/javafxports/8u-dev-rt/pull-requests/5/fix-jfxport-41/diff

JavaFXPorts的新版本(8.60.7版本)。 這些修復程序包含在JavaFXPorts 8.60.7中,它是released on March 31, 2016