Usage Examples
Register and Deregister File Open Handler
from omni.kit.window.content_browser_registry import register_file_open_handler, deregister_file_open_handler
# Define a callback function for the file open handler
def on_open_file():
print("File open handler invoked!")
# Register a file open handler
register_file_open_handler(name="my_file_open_handler", open_fn=on_open_file, file_type=lambda: True)
# Deregister the file open handler
deregister_file_open_handler(name="my_file_open_handler")
Register and Deregister Selection Handlers
from omni.kit.window.content_browser_registry import register_selection_handler, deregister_selection_handler
# Define a selection handler function
def on_selection():
print("Selection handler invoked!")
# Register a selection handler
register_selection_handler(handler=on_selection)
# Deregister the selection handler
deregister_selection_handler(handler=on_selection)
Register and Deregister Search Delegate
from omni.kit.window.content_browser_registry import register_search_delegate, deregister_search_delegate
# Define a mock search delegate (assuming SearchDelegate is a valid class)
class MockSearchDelegate:
def search(self, query):
print(f"Search delegate invoked with query: {query}")
# Create an instance of the mock search delegate
mock_search_delegate = MockSearchDelegate()
# Register the search delegate
register_search_delegate(search_delegate=mock_search_delegate)
# Deregister the search delegate
deregister_search_delegate(search_delegate=mock_search_delegate)