< prev index next >

modules/javafx.web/src/main/java/javafx/scene/web/HTMLEditorSkin.java

Print this page




 289                 }
 290             });
 291         });
 292 
 293 
 294         webView.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
 295             applyTextFormatting();
 296             if (event.getCode() == KeyCode.CONTROL || event.getCode() == KeyCode.META) {
 297                 return;
 298             }
 299             if (event.getCode() == KeyCode.TAB && !event.isControlDown()) {
 300                 if (!event.isShiftDown()) {
 301                     /*
 302                     ** if we are in either Bullet or Numbers mode then the
 303                     ** TAB key tells us to indent again.
 304                     */
 305                     if (getCommandState(BULLETS.getCommand()) || getCommandState(NUMBERS.getCommand())) {
 306                         executeCommand(INDENT.getCommand(), null);
 307                     }
 308                     else {

 309                         executeCommand(INSERT_TAB.getCommand(), null);

 310                     }
 311                 }
 312                 else {
 313                     /*
 314                     ** if we are in either Bullet or Numbers mode then the
 315                     ** Shift-TAB key tells us to outdent.
 316                     */
 317                     if (getCommandState(BULLETS.getCommand()) || getCommandState(NUMBERS.getCommand())) {
 318                         executeCommand(OUTDENT.getCommand(), null);
 319                     }
 320                 }
 321                 return;
 322             }
 323             // Work around for bug that sends events from ColorPicker to this Scene
 324             if ((fgColorButton != null && fgColorButton.isShowing()) ||
 325                 (bgColorButton != null && bgColorButton.isShowing())) {
 326                 return;
 327             }
 328             Platform.runLater(() -> {
 329                 if (webPage.getClientSelectedText().isEmpty()) {


 431                                    scene.getWindow() == null ||
 432                                    !scene.getWindow().isFocused() ||
 433                                    !(scene.getFocusOwner() instanceof TextInputControl /*||
 434                                      getScene().getFocusOwner() instanceof WebView*/)) {
 435                             FXVK.detach();
 436                         }
 437                     }
 438                 }
 439             });
 440         });
 441 
 442         webView.getEngine().getLoadWorker().workDoneProperty().addListener((observable, oldValue, newValue) -> {
 443             Platform.runLater(() -> {
 444                 webView.requestLayout();
 445             });
 446 
 447             double totalWork = webView.getEngine().getLoadWorker().getTotalWork();
 448             if (newValue.doubleValue() == totalWork) {
 449                 cachedHTMLText = null;
 450                 Platform.runLater(() -> {
 451                     setDesignMode("on");
 452                     setContentEditable(true);
 453                     updateToolbarState(true);
 454                     updateNodeOrientation();
 455                     executeCommand(STYLEWITHCSS.getCommand(), "true");
 456                 });
 457             }
 458         });
 459 
 460         enableToolbar(true);
 461         setHTMLText(cachedHTMLText);
 462 
 463         engine = new ParentTraversalEngine(getSkinnable(), new Algorithm() {
 464             @Override
 465             public Node select(Node owner, Direction dir, TraversalContext context) {
 466                 return cutButton;
 467             }
 468 
 469             @Override
 470             public Node selectFirst(TraversalContext context) {
 471                 return cutButton;




 289                 }
 290             });
 291         });
 292 
 293 
 294         webView.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
 295             applyTextFormatting();
 296             if (event.getCode() == KeyCode.CONTROL || event.getCode() == KeyCode.META) {
 297                 return;
 298             }
 299             if (event.getCode() == KeyCode.TAB && !event.isControlDown()) {
 300                 if (!event.isShiftDown()) {
 301                     /*
 302                     ** if we are in either Bullet or Numbers mode then the
 303                     ** TAB key tells us to indent again.
 304                     */
 305                     if (getCommandState(BULLETS.getCommand()) || getCommandState(NUMBERS.getCommand())) {
 306                         executeCommand(INDENT.getCommand(), null);
 307                     }
 308                     else {
 309                         setDesignMode("on");
 310                         executeCommand(INSERT_TAB.getCommand(), null);
 311                         setDesignMode("off");
 312                     }
 313                 }
 314                 else {
 315                     /*
 316                     ** if we are in either Bullet or Numbers mode then the
 317                     ** Shift-TAB key tells us to outdent.
 318                     */
 319                     if (getCommandState(BULLETS.getCommand()) || getCommandState(NUMBERS.getCommand())) {
 320                         executeCommand(OUTDENT.getCommand(), null);
 321                     }
 322                 }
 323                 return;
 324             }
 325             // Work around for bug that sends events from ColorPicker to this Scene
 326             if ((fgColorButton != null && fgColorButton.isShowing()) ||
 327                 (bgColorButton != null && bgColorButton.isShowing())) {
 328                 return;
 329             }
 330             Platform.runLater(() -> {
 331                 if (webPage.getClientSelectedText().isEmpty()) {


 433                                    scene.getWindow() == null ||
 434                                    !scene.getWindow().isFocused() ||
 435                                    !(scene.getFocusOwner() instanceof TextInputControl /*||
 436                                      getScene().getFocusOwner() instanceof WebView*/)) {
 437                             FXVK.detach();
 438                         }
 439                     }
 440                 }
 441             });
 442         });
 443 
 444         webView.getEngine().getLoadWorker().workDoneProperty().addListener((observable, oldValue, newValue) -> {
 445             Platform.runLater(() -> {
 446                 webView.requestLayout();
 447             });
 448 
 449             double totalWork = webView.getEngine().getLoadWorker().getTotalWork();
 450             if (newValue.doubleValue() == totalWork) {
 451                 cachedHTMLText = null;
 452                 Platform.runLater(() -> {

 453                     setContentEditable(true);
 454                     updateToolbarState(true);
 455                     updateNodeOrientation();
 456                     executeCommand(STYLEWITHCSS.getCommand(), "true");
 457                 });
 458             }
 459         });
 460 
 461         enableToolbar(true);
 462         setHTMLText(cachedHTMLText);
 463 
 464         engine = new ParentTraversalEngine(getSkinnable(), new Algorithm() {
 465             @Override
 466             public Node select(Node owner, Direction dir, TraversalContext context) {
 467                 return cutButton;
 468             }
 469 
 470             @Override
 471             public Node selectFirst(TraversalContext context) {
 472                 return cutButton;


< prev index next >