끌어서 놓기 작업 중에 팝업 대화 상자를 사용하고 있습니다. 드롭이 발생하면 대화 상자가 팝업되고 해제 될 때 이벤트 체인이 계속되어야하며 드래그 작업이 끝날 때 어떤 일이 일어나도록 허용해야합니다. 팝업 대화 상자가 FX 인 경우 아무런 문제가 없습니다. 그러나 Gluon이라면 드래그 완료 작업이 발생하지 않습니다. 배경이 빨간색으로 변경하는에대화 상자가 끌기 완료 이벤트를 전파하지 않습니다.
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Label;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import com.gluonhq.charm.glisten.mvc.View;
public class MainView extends View {
HBox root;
public MainView(String name) {
super(name);
Label source = new Label("Source");
configureDragSource(source);
Label target = new Label("Target");
configureDragTarget(target);
Label popupTarget = new Label("Popup Target");
configureDragPopupTarget(popupTarget);
root = new HBox(40, source, target, popupTarget);
setCenter(root);
}
private void configureDragSource(Label source) {
source.setOnDragDetected(e -> {
root.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));
Dragboard db = source.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
content.put(DataFormat.PLAIN_TEXT, source.getText());
db.setContent(content);
});
source.setOnDragDone(e -> root.setBackground(new Background(new BackgroundFill(null, null, null))));
}
private void configureDragTarget(Label target) {
target.setOnDragOver(e -> e.acceptTransferModes(TransferMode.ANY));
}
private void configureDragPopupTarget(Label popupTarget) {
popupTarget.setOnDragOver(e -> e.acceptTransferModes(TransferMode.ANY));
popupTarget.setOnDragDropped(e -> {
javafx.scene.control.Alert popup1 = new javafx.scene.control.Alert(AlertType.INFORMATION);
com.gluonhq.charm.glisten.control.Alert popup2 = new com.gluonhq.charm.glisten.control.Alert(AlertType.INFORMATION);
popup1.showAndWait();
});
}
}
소스를 드래그해야합니다 여기
은 샘플 코드입니다. 드래그 작업이 완료되면 배경이 기본값으로 돌아갑니다. 일반 드롭 대상은 아무 것도하지 않고 색상 변경이 적용됩니다. 그러나 팝업 타겟을 드롭 할 때 대화 상자가 나타나고 닫히면 글자 대화 상자가 아닌 FX 대화 상자에서만 색상이 변경됩니다.popup1.showAndWait();
을
popup2
으로 변경하십시오.
이 중요한 경우이 응용 프로그램 클래스
import com.gluonhq.charm.glisten.application.MobileApplication;
public class TestApplication extends MobileApplication {
@Override
public void init() {
addViewFactory(HOME_VIEW,() -> new MainView(HOME_VIEW));
}
public static void main(String[] args) {
launch(args);
}
}
이며, 이는 Gradle을 빌드 파일입니다
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.5'
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'eclipse'
jar {
manifest {
attributes 'Main-Class': 'com.test.TestApplication'
}
}
jfxmobile {
downConfig {
version = '3.3.0'
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
compileSdkVersion = 19
// manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.test.TestApplication'
dependencies {
compile 'com.gluonhq:charm:4.3.5'
}
task wrapper(type: Wrapper) {
gradleVersion = '4.2'
}
이 compile 'com.gluonhq:charm:4.3.7'
및 4.4.0에도 발생합니다.
Java 8 b141에서 실행 중입니다. 왜 이런 일이 생길까요? 이거 버그 야?
대화 상자의 javadoc 페이지에'dialog.setContent (new Label ("그냥 일반 대화 상자, 평이하고 단순한");'''가 없습니다. – Mark
데스크탑에서'popup2'를 실행할 때 NPE가 보입니까? –
@ JoséPereda 아니요. 또한 이벤트 처리기 내부에서 캐치 시도를 추가했으며 아무 것도 잡히지 않았습니다. 특정 장소를보아야합니까? – Mark