ActiveUI

ActiveUI

  • User Guide
  • Developer Documentation

Home > @activeviam/activeui-sdk > useSelectedWidget

useSelectedWidget() function

A React hook that provides the API of the currently selected widget to child components, or undefined if no widget is selected.

Signature:

export declare function useSelectedWidget(): SelectedWidgetProps;

Returns:

SelectedWidgetProps

Remarks

A widget is considered as selected when:

  • It has just been loaded

  • It has been actively selected by the user by clicking on it or its background

Example

// Custom button to show/hide the selected widget's title bar.
function ShowHideTitleToggle() {
  const {selectedWidgetApi} = useSelectedWidget();
  return (
    <button
      onClick={() => {
        selectedWidgetApi.setBookmarkShowTitleBar(!selectedWidgetApi.getBookmarkShowTitleBar());
      }}
    >
      Show/hide title bar
    </button>
  );
}

  • useSelectedWidget() function
  • Remarks
  • Example
Copyright © 2023 ActiveViam