【问题标题】:Charm 4.0.0 PopupView shows up only onceCharm 4.0.0 PopupView 只显示一次
【发布时间】:2016-11-01 01:41:58
【问题描述】:

我有一组使用PopupView 的控件。 自 Charm 4.0.0 更新以来,它们表现出一些奇怪的行为。

当我选择了包含在 PopupView 中的 Node 时,PopupView 会关闭。现在 PopupView 被关闭但立即再次出现。此外,一旦我在 PopupView 之外单击它就会关闭,但我无法再次显示它。

我已经使用Gluon javadoc 中的示例对其进行了测试,并在第二个问题上遇到了相同的行为:

 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");
         }
       };
     });
   }
 } 

【问题讨论】:

    标签: gluon gluon-mobile


    【解决方案1】:

    感谢您的报告。我已经提交了一个问题,以便尽快解决。

    与此同时,PopupView 的解决方法可以是:

    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(); 
        }
    };
    

    【讨论】:

    • AutoCompleteTextField 显示相同的行为,因为它使用PopupView 来自动完成弹出窗口。由于 PopupView 未公开,因此无法应用此解决方法。怎么解决?
    猜你喜欢
    • 1970-01-01
    • 2020-10-25
    • 2011-01-23
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-14
    • 1970-01-01
    相关资源
    最近更新 更多