Skip to main content
Jul 31, 2024 1:20 PM UTC
Solved

programmatic way of knowing when the shape selection has changed?

Hello,

Is there a programmatic way of knowing when the shape selection has changed?

I have a right context in my package and custom shapes.  My custom shapes have a  custom data property on it called q_type.  What I want to do is:

  1. Click open the right click context panel.  Keep it open.
  2. Select Shape1 which has a custom data property “q_type” value of “foo”.  Show the “foo” form in the right click panel.  
  3. User now selects Shape2 which has a custom data property “q_type” value of “bar”.  Show the “bar” form.

In my extension app, can I register a method to a on selection changed event?

Thanks, Dan

Michael B
Michael BAnswer
Lucid product team
Aug 1, 2024 2:07 PM UTC

Take a look at https://developer.lucid.co/extension-sdk/#classes_ui_viewport-Viewport_hookselection.  I think that gives you what you need.

Comments

Michael B
Lucid product team
Jul 31, 2024 7:51 PM UTC

Hello PromitaDan,

 

We are reviewing your question now and will be in touch with something soon.

Translate
Michael B
Michael BAnswer
Lucid product team
Aug 1, 2024 2:07 PM UTC

Take a look at https://developer.lucid.co/extension-sdk/#classes_ui_viewport-Viewport_hookselection.  I think that gives you what you need.

Translate
Aug 4, 2024 3:41 PM UTC

This is exactly what I need.  I actually read the documentation for viewport and missed this method.

I added it to my extension.ts file.  do i need to unhook it and if so, what is the approach?

Translate
Michael B
Lucid product team
Aug 5, 2024 8:48 PM UTC

Hello again,

You do not need to unhook the selection as the extension framework handles disposing it for you.  However, if you no longer needed the functionality and wanted to remove it yourself, you could via https://developer.lucid.co/extension-sdk/#classes_ui_viewport-Viewport_unhookselection

Translate