2
コンテナのSpanButtonリードを作成すると、イベントは受信されません。私はデバッグを試みましたが、なぜそれが動作しないのか理解できませんでした。それはCN1エラーのようですが、私は何か誤解しているかもしれません。ここで作成時にSpanButtonを動作させるには?
は、問題を再現するために、テストケースです:
Form hi = new Form("Welcome", BoxLayout.y());
//test case shows that when you make a normal Button lead for a Container,
//it works as expected.
//Doing the same with a SpanButton doesn't work.
//When you click button it correctly hides the Label.
//Clicking spanButton doesn't hide the label.
//
//Test also shows a second issue: when adding a Command to a SpanButton,
//the Command text is shown in parallel with the SpanButton's text
//edit Button works normal
Button button = new Button("Normal Button works");
Label hide2 = new Label("Now you see me, now you don't2");
Command cmd2 = Command.create("CmdTxt2", null, (ev) -> {
hide2.setHidden(!hide2.isHidden());
hi.revalidate();
});
button.setCommand(cmd2);
Label editButtonLabel2 = new Label();
FontImage.setMaterialIcon(editButtonLabel2, FontImage.MATERIAL_CHEVRON_RIGHT); // [>]
Container cont2 = BorderLayout.centerEastWest(button, editButtonLabel2, null);
cont2.setLeadComponent(button); //for a normal button, the lead works correctly
hi.add(cont2);
hi.add(hide2);
//with SpanButton it doesn't work:
SpanButton spanButton = new SpanButton("SpanButton does not work");
Label hide = new Label("Now you see me, now you don't");
Command cmd = Command.create("CmdText", null, (ev) -> {
hide.setHidden(!hide.isHidden());
hi.revalidate();
});
spanButton.setCommand(cmd);
Label editButtonLabel = new Label();
FontImage.setMaterialIcon(editButtonLabel, FontImage.MATERIAL_CHEVRON_RIGHT); // [>]
Container cont = BorderLayout.centerEastWest(spanButton, editButtonLabel, null);
cont.setLeadComponent(spanButton); //spanButton made lead for cont, so should receive all events for cont, but doesn't
hi.add(cont);
hi.add(hide);
hi.show();
はい。これがループに入ると、先導コンポーネントをリーダーにすることはできません。 –
ありがとうShai、あなたはそれを文書化できますか(SpanButtonを通常のButtonの代わりに使用することは簡単に考えられるので、1日のデバッグは無駄です)そして、ダイアモンドに感謝します。あなたの提案がうまくいくと思います。 – user1246562