Giter VIP home page Giter VIP logo

vaadin-lazytooltip's Introduction

vaadin-lazytooltip

Lazy Tooltip Add-on is an add-on for Vaadin.

Version 2.0.0 can be used with Vaadin 8.2+ (master branch).

Version 1.0.0 can be used with Vaadin 7.3+ (vaadin7 branch).

Installation

The Vaadin add-ons installation is described on the Vaadin website: https://vaadin.com/directory/help/using-vaadin-add-ons/

Note that the Lazy Tooltip Add-on will replace the VTooltip widget with VLazyTooltip (see LazyTooltipWidgetset.gwt.xml).

How to Build

This add-on is built with maven. To build and run the demo:

mvn clean install

cd lazytooltip-demo

mvn jetty:run

To see the demo, navigate to http://localhost:8080/

Usage

A Lazy Tooltip can be added to any Vaadin component:

LazyTooltip lazyTooltip = LazyTooltip.addToComponent(component);

Once added to a component, you should define a handler for the tooltip:

lazyTooltip.setTooltipHandler(handler);

A Lazy Tootlip handler must implement generateTooltip():

public interface LazyTooltipHandler {
    public void generateTooltip(LazyTooltipUpdater updater);
}

generateTooltip() is invoked (lazily) when a tooltip is requested by the client-side widget. LazyTooltipUpdater is the interface that allows the tooltip to be updated. updateTooltip(String tooltip) must be used to update the content of the tooltip. The content of the tooltip will be displayed as HTML (see AbstractComponent.setDescription(String description)).

With Java 8, you could use a lambda expression to define the tooltip handler:

lazyTooltip.setTooltipHandler((LazyTooltipUpdater updater) ->
    updater.updateTooltip("This is a static tooltip"));

Note that updateTooltip() must be invoked from the Vaadin UI thread to properly update the client component.

updateTooltip() can also be called multiple times and the tooltip will be updated dynamically on the client side as long as the tooltip is open.

License

vaadin-lazytooltip is released under the Apache License, Version 2.0.

vaadin-lazytooltip's People

Contributors

peergynt avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

a-schild antea

vaadin-lazytooltip's Issues

Please merge pull #2 request for Vaadin 8

Pull request #2 contains version which can be used with vaadin 8.
No code changes have been needed, with the exception of the Demo UI which does not have the Readonly stuff

Grid tooltips do not display

Grid.setRowDescriptionGenerator() and Grid.setColumnDescriptionGenerator() tooltips do not display. When you hover over a grid row/cell nothing happens.

// Example grid where tooltips are not displayed but should be:
Grid g = new Grid();
g.addColumn("c1");
g.addColumn("c2");
g.addRow("row 1", "cell 1.1");
g.addRow("row 2", "cell 2.1");
g.setRowDescriptionGenerator(rowRef -> {
  return "This is a roll description";
});

A solution maybe to change line VLazyTooltip.handleShowHide(..)

// code inside handleShowHide method
if (nativeEvent) {
  // we need to get the cell that mouseover event occurred on, 
  // so we shouldn't be jumping to the parent immediately
  element = Element.as(event.getEventTarget());
  // original:
  // Widget widget = getParentWidget(Element.as(event.getEventTarget()));
  // if (widget != null) {
  //   element = widget.getElement();
  // }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.