ドラッグアンドドロップ操作中にポップアップダイアログを使用しています。ドロップが発生すると、ダイアログがポップアップし、解除されると、イベントチェーンが継続され、ドラッグ操作が終了したときに何かが起きるようになります。ポップアップダイアログが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