Charm 4.0.0 PopupView shows up only once

喜欢而已 提交于 2019-12-02 18:09:50

问题


I have a set of Controls which use PopupView. Since the update to Charm 4.0.0, they show some weird behaviour.

When I selected a Node contained in the PopupView, the PopupView used to get closed. Now the PopupView gets closed but immediately shows up again. Furthermore as soon as I click outside the PopupView it gets closed, but I am not able to show it again.

I've tested it with the example from the Gluon javadoc and experienced the same behaviour regarding the second issue:

 public class MyApp extends MobileApplication{
   private Button button;
   private PopupView popupView;

   @Override
   public void init() {
       addViewFactory(HOME_VIEW, ()  -> {
       button = new Button("Click");
       button.setOnAction(event  -> popupView.show());

       popupView = new PopupView(button);

       VBox vBox = new VBox();
       vBox.getChildren().addAll(new Label("Choice 1"), new Label("Choice 2"), new Label("Choice 3"));
       vBox.setSpacing(5);

       popupView.setContent(vBox);

       return new View(button) {
         @Override
         protected void updateAppBar(AppBar appBar) {
           appBar.setTitleText("PopupView");
         }
       };
     });
   }
 } 

回答1:


Thanks for reporting. I've filed an issue so it get fixed as soon as possible.

In the meantime, a workaround for the PopupView can be this:

PopupView popupView = new PopupView(button) {

    private final GlassPane glassPane = MobileApplication.getInstance().getGlassPane();

        {
            this.setOnMouseReleased(e -> this.hide());
        }

    @Override public void show() {
        // before showing add the glassPane (issue #2):
        this.mobileLayoutPaneProperty().set(glassPane);
        super.show(); 
    }

    @Override public void hide() {
        // when hiding don't show again (issue #1):
        setShowing(false);
        super.hide(); 
    }
};


来源:https://stackoverflow.com/questions/40353023/charm-4-0-0-popupview-shows-up-only-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!