@Override public TriggerActionMapping getOverrideMapping() { if (behaviorContributor != null) { TriggerActionMapping x = new TriggerActionMapping(); behaviorContributor.initializeMapping(new MappingRegistry() { @Override public void map(String combo, TextEditAction action) { x.map(combo, action); } @Override public void map(char typedChar, TextEditAction action) { x.map(typedChar, action); } @Override public void mapConditional(String conditionId, Supplier<Boolean> condition, String combo, TextEditAction action) { x.mapConditional(conditionId, condition, combo, action); } @Override public void mapConditional(String conditionId, Supplier<Boolean> condition, char typedChar, TextEditAction action) { x.mapConditional(conditionId, condition, typedChar, action); } }); x.subscribe((e, c)->behaviorContributor.handle(e)); return x; } return super.getOverrideMapping(); }
/** * Create a new behavior * * @param styledText * the styled text control */ public StyledTextBehavior(StyledTextArea styledText) { this.styledText = styledText; this.positionUpdaterTop.setCycleCount(Animation.INDEFINITE); this.positionUpdaterBottom.setCycleCount(Animation.INDEFINITE); styledText.addEventHandler(KeyEvent.KEY_PRESSED, this::onKeyPressed); styledText.addEventHandler(KeyEvent.KEY_TYPED, this::onKeyTyped); styledText.addEventHandler(MouseEvent.MOUSE_PRESSED, this::onMousePressed); styledText.addEventHandler(TextPositionEvent.TEXT_POSITION_MOVED, this::onTextPositionMoved); this.keyTriggerMapping.subscribe(this::defaultHandle); initKeymapping(this.keyTriggerMapping); styledText.addEventHandler(TextPositionEvent.TEXT_POSITION_PRESSED, this::onTextPositionPressed); styledText.addEventHandler(TextPositionEvent.TEXT_POSITION_CLICKED, this::onTextPositionClicked); styledText.addEventHandler(TextPositionEvent.TEXT_POSITION_RELEASED, this::onTextPositionReleased); styledText.addEventHandler(TextPositionEvent.TEXT_POSITION_DRAGGED, this::onTextPositionDragged); styledText.addEventHandler(TextPositionEvent.TEXT_POSITION_DRAG_DETECTED, this::onTextPositionDragDetected); this.keyTriggerMapping.overrideProperty().bind(styledText.overrideActionMappingProperty()); }