2016-05-23 80 views
0

我已經創建了一個使用JavaFX HTMLEditor組件的聊天,發送消息之後,由於您按下發送按鈕8,編輯器不再被聚焦)。我想以某種方式關注編輯,我已經使用Google搜索但沒有找到答案,希望有人能幫助我。JavaFX HTMLEditor - 焦點webView(TextArea)

回答

0
void editorWebViewRequestFocus() 
    { 
    final WebView view = (WebView) ((GridPane) ((HTMLEditorSkin) editor.getSkin()).getChildren().get(0)).getChildren().get(2); 

    Platform.runLater(() -> 
    { 
     view.fireEvent(new MouseEvent(MouseEvent.MOUSE_PRESSED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false, 
      false, false, false, false, false, false, null)); 
     editor.requestFocus(); 
     view.fireEvent(new MouseEvent(MouseEvent.MOUSE_RELEASED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false, 
      false, false, false, false, false, false, null)); 
    }); 
    }