当前位置: 首页>>代码示例>>Java>>正文


Java CodeArea.setOnKeyPressed方法代码示例

本文整理汇总了Java中org.fxmisc.richtext.CodeArea.setOnKeyPressed方法的典型用法代码示例。如果您正苦于以下问题:Java CodeArea.setOnKeyPressed方法的具体用法?Java CodeArea.setOnKeyPressed怎么用?Java CodeArea.setOnKeyPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fxmisc.richtext.CodeArea的用法示例。


在下文中一共展示了CodeArea.setOnKeyPressed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GroovyEditorComponent

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
/**
 * Instantiates a new Groovy editor component.
 *
 * @param editable the editable
 */
public GroovyEditorComponent(final boolean editable) {

    codeArea = new CodeArea();
    codeArea.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved()))
            .subscribe(change -> codeArea.setStyleSpans(0, getStyleSpans(codeArea.getText())));
    codeArea.prefHeightProperty().bind(heightProperty());
    codeArea.prefWidthProperty().bind(widthProperty());
    codeArea.setEditable(editable);
    codeArea.setOnKeyReleased(UIUtils::consumeIfIsNotHotKey);
    codeArea.setOnKeyPressed(UIUtils::consumeIfIsNotHotKey);


    FXUtils.addToPane(codeArea, this);
    FXUtils.addClassesTo(this, CSSClasses.TEXT_EDITOR_TEXT_AREA, CSSClasses.GROOVY_EDITOR_COMPONENT);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:GroovyEditorComponent.java

示例2: FXMLTextArea

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public FXMLTextArea() {
	codeArea = new CodeArea();
	codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

	codeArea.richChanges().subscribe(change -> {
		codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
	});

	codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
		int start = newval.getStart();
		int end = newval.getEnd();
		int caretColumn = codeArea.getCaretColumn();

		String format = String.format("line : %d selectionStart : %d selectionEnd : %d column : %d  anchor : %d",
				codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1, codeArea.getAnchor());

		lblLineInfo.setText(format);
	});

	codeArea.setOnKeyPressed(this::codeAreaKeyClick);
	lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
	lblLineInfo.setMinHeight(USE_COMPUTED_SIZE);
	lblLineInfo.setMaxHeight(USE_COMPUTED_SIZE);
	this.setCenter(codeArea);
	this.setBottom(lblLineInfo);
	// this.getChildren().add(codeArea);
	this.getStylesheets().add(FXMLTextArea.class.getResource("java-keywords.css").toExternalForm());

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:30,代码来源:FXMLTextArea.java

示例3: initialize

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@FXML
public void initialize() {
	codeArea = new CodeArea();
	codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
	codeArea.textProperty().addListener(new ChangeListener<String>() {

		@Override
		public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
			// Tab 없이 처리되는 클래스들도 있음....
			DockTab tab2 = SimpleTextView.this.tab;
			if (tab2 != null) {
				if (tab2.getText().charAt(0) == '*') {
					return;
				}
				String modifyTabName = "*".concat(tab2.getText());
				tab2.setText(modifyTabName);
			}

		}
	});

	codeArea.setOnKeyPressed(ev -> {

		if (ev.getCode() == KeyCode.S && ev.isControlDown()) {
			if (ev.isConsumed())
				return;
			miSaveOnAction();
			ev.consume();
		} else if (ev.getCode() == KeyCode.N && ev.isControlDown()) {
			if (ev.isConsumed())
				return;

			miNewOnAction();
			ev.consume();
		}

	});
	initHelpers();
	initGraphics();

	// miSaveAs.setAccelerator(new KeyCodeCombination(KeyCode.S,
	// KeyCombination.CONTROL_DOWN));

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:45,代码来源:SimpleTextView.java

示例4: SqlKeywords

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public SqlKeywords() {

		codeArea = new CodeArea();

		codeHelperDeligator = new SqlCodeAreaHelper(codeArea);

		codeArea.appendText("");
		codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

		//		codeArea.richChanges().subscribe(change -> {
		//			Platform.runLater(() -> {
		//				codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
		//
		//			});
		//		});

		codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
				.successionEnds(Duration.ofMillis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
				.filterMap(t -> {
					if (t.isSuccess()) {
						return Optional.of(t.get());
					} else {
						t.getFailure().printStackTrace();
						return Optional.empty();
					}
				}).subscribe(this::applyHighlighting);

		/**CodeArea 'Tab' Size handler *************************************************************/
		//17.01.14 Deprecated
		//codeArea.addEventHandler(KeyEvent.KEY_PRESSED, new CodeAreaTabSizeHandler(codeArea));
		
		// 마우스 클릭이벤트 정의
		codeArea.addEventHandler(KeyEvent.KEY_PRESSED, this::codeAreaKeyClick);
		

		codeArea.setOnKeyPressed(this::codeAreaKeyClick);
		//
		//		codeArea.setOnMouseClicked(defaultSelectionHandler);

		// 선택라인정보 보여주는 기능 추가.
		codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
			int start = newval.getStart();
			int end = newval.getEnd();
			int caretColumn = codeArea.getCaretColumn();

			String format = String.format("line : %d selectionStart : %d selectionEnd : %d column : %d ",
					codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1);

			lblLineInfo.setText(format);
		});

		lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
		this.setCenter(codeArea);
		this.setBottom(lblLineInfo);
		// this.getChildren().add();
		this.getStylesheets().add(SqlKeywords.class.getResource("java-keywords.css").toExternalForm());
	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:58,代码来源:SqlKeywords.java


注:本文中的org.fxmisc.richtext.CodeArea.setOnKeyPressed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。