iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
623 stars 211 forks source link

Display data using tooltips upon hover #2039

Closed kiranshetty07061999 closed 3 years ago

kiranshetty07061999 commented 3 years ago
Screenshot 2021-08-11 at 5 40 39 PM

Hey, I want to display data on the components of the imodel using tooltip hover. I have got the codes from this link below https://github.com/imodeljs/imodeljs/blob/master/ui/ninezone/src/ui-ninezone/popup/Tooltip.tsx#L37

I am getting data from iconsole. How do i map it on the model?

I have attatched the screenshot of the model above

Please help

I

pmconne commented 3 years ago

When you mouse over an element in a viewport, a tooltip showing some information about that element is displayed. Are you asking to replace or augment the information displayed in that tooltip? If not, please clarify your question. If so, please clarify what "data from iconsole" means and how it relates to the contents of the iModel.

kiranshetty07061999 commented 3 years ago

Nope..I am not able to display the tooltip upon hover at all...

pmconne commented 3 years ago

If you don't see a default tooltip when mousing over an element in the viewport while the browser window has focus, check console for any errors. You should always see something. Does the element "flash" (change color or brighten in color)? Please supply the information requested in previous reply.

DanEastBentley commented 3 years ago

Before calling the IModelApp.startup function, are you setting the opts.iModelApp.notifications variable similar to the following:

import { AppNotificationManager } from "@bentley/ui-framework";
. . .
  const opts: WebViewerAppOpts & NativeAppOpts = {
    iModelApp: {
 . . .
      notifications: new AppNotificationManager(),
 . . .
    },
 . . .
  };

  // Start the app.
  await SampleAppIModelApp.startup(opts);

The implementation of NotificationManager.openToolTip or ._showToolTip puts the tooltip on the screen.

kiranshetty07061999 commented 3 years ago

I have tried using the code from the below link

https://www.itwinjs.org/sample-showcase/?group=Viewer+Features&sample=tooltip-customize-sample&gallery=false&imodel=Metrostation+Sample

But i am not able to find the following packages in npm

@itwinjs-sandbox/hooks/useSampleWidge and @itwinjs-sandbox

Any idea how to access them?

Ellord207 commented 3 years ago

This package is intended just to support the samples you linked to, and not for users consumption. What "useSampleWidget" does is create the "Sample Information" panel in the sample.

For more information about using the showcase samples in your own app, we have a tutorial for it. https://developer.bentley.com/tutorials/adding-showcase-widgets-to-your-itwin-viewer/