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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ---
  2. title: PopupView
  3. order: 29
  4. layout: page
  5. ---
  6. [[components.popupview]]
  7. = [classname]#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,
  36. new Table(null, TableExample.generateContent()));
  37. // A component to open the view
  38. Button button = new Button("Show table", click -> // Java 8
  39. popup.setPopupVisible(true));
  40. layout.addComponents(button, popup);
  41. ----
  42. When the pop-up is opened or closed, a [classname]#PopupVisibilityEvent# is
  43. fired, which can be handled with a [interfacename]#PopupVisibilityListener#
  44. added with [methodname]#setPopupVisibilityListener()#.
  45. [source, java]
  46. ----
  47. // Fill the pop-up content when it's popped up
  48. popup.addPopupVisibilityListener(event -> {
  49. if (event.isPopupVisible()) {
  50. popupContent.removeAllComponents();
  51. popupContent.addComponent(new Table(null,
  52. TableExample.generateContent()));
  53. }});
  54. ----
  55. [[components.popupview.css]]
  56. == CSS Style Rules
  57. [source, css]
  58. ----
  59. .v-popupview {}
  60. .v-overlay-container {
  61. .v-popupview-popup {
  62. .popupContent { }
  63. }
  64. }
  65. ----
  66. In minimalized state, the component has [literal]#++v-popupview++# style. When
  67. popped up, the pop-up content is shown in a [literal]#++v-popupview-popup++#
  68. overlay element under the [literal]#++v-overlay-container++#, which is contains
  69. all floating overlays outside the component hierarchy.