You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

components-popupview.asciidoc 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ---
  2. title: PopupView
  3. order: 29
  4. layout: page
  5. ---
  6. [[components.popupview]]
  7. = PopupView
  8. ifdef::web[]
  9. [.sampler]
  10. image:{live-demo-image}[alt="Live Demo", link="http://demo.vaadin.com/sampler/#ui/structure/popup-view"]
  11. endif::web[]
  12. The [classname]#PopupView# component allows opening a pop-up view either by
  13. clicking on a link or programmatically. The component has two representations: a
  14. minimized textual representation and the popped-up content. The view can contain
  15. any components. The view closes automatically when the mouse pointer moves
  16. outside the view.
  17. In the following, we have a popup view with a text field and a button that opens
  18. automatically when the user clicks on a "Open the popup" link:
  19. [source, java]
  20. ----
  21. // Content for the PopupView
  22. VerticalLayout popupContent = new VerticalLayout();
  23. popupContent.addComponent(new TextField("Textfield"));
  24. popupContent.addComponent(new Button("Button"));
  25. // The component itself
  26. PopupView popup = new PopupView("Pop it up", popupContent);
  27. layout.addComponent(popup);
  28. ----
  29. If the textual minimized representation is not given (a null is given), the
  30. component is invisible in the minimized state. The pop-up can be opened
  31. programmatically by calling [methodname]#setPopupVisible(true)#. For example:
  32. [source, java]
  33. ----
  34. // A pop-up view without minimalized representation
  35. PopupView popup = new PopupView(null, myComponent);
  36. // A component to open the view
  37. Button button = new Button("Show details", click ->
  38. popup.setPopupVisible(true));
  39. layout.addComponents(button, popup);
  40. ----
  41. When the pop-up is opened or closed, a [classname]#PopupVisibilityEvent# is
  42. fired, which can be handled with a [interfacename]#PopupVisibilityListener#
  43. added with [methodname]#setPopupVisibilityListener()#.
  44. [source, java]
  45. ----
  46. // Fill the pop-up content when it's popped up
  47. popup.addPopupVisibilityListener(event -> {
  48. if (event.isPopupVisible()) {
  49. popupContent.removeAllComponents();
  50. popupContent.addComponent(new Table(null,
  51. TableExample.generateContent()));
  52. }});
  53. ----
  54. [[components.popupview.css]]
  55. == CSS Style Rules
  56. [source, css]
  57. ----
  58. .v-popupview {}
  59. .v-overlay-container {
  60. .v-popupview-popup {
  61. .popupContent { }
  62. }
  63. }
  64. ----
  65. In minimalized state, the component has [literal]#++v-popupview++# style. When
  66. popped up, the pop-up content is shown in a [literal]#++v-popupview-popup++#
  67. overlay element under the [literal]#++v-overlay-container++#, which is contains
  68. all floating overlays outside the component hierarchy.