For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-native-api/lynx-extension-module/on-lynx-view-create.md.
Lynx
  • English
  • OnLynxViewCreate

    OnLynxViewCreate is a virtual lifecycle method in the LynxExtensionModule class. It is called by the Lynx framework when a new lynx_view instance, associated with this extension module, is created.

    This callback is always invoked on the UI thread. It serves as an entry point for initializing resources or performing setup tasks that are specific to a given lynx_view.

    Method Signature

    virtual void OnLynxViewCreate(lynx_view_t* lynx_view);

    Parameters

    NameTypeDescriptionRequired
    lynx_viewlynx_view_t*A pointer to the newly created lynx_view instance. You can use this to interact with the view, such as attaching clients or listeners.Yes

    Usage

    You should override this method in your custom subclass of LynxExtensionModule to perform any necessary initialization when a Lynx page is created. For example, you might want to set up platform-specific listeners or prepare data sources.

    Example

    #include "lynx_extension_module.h"
    #include "lynx_view.h"
    
    class MyExtensionModule : public lynx::pub::LynxExtensionModule {
    public:
        void OnLynxViewCreate(lynx_view_t* lynx_view) override {
            // A new lynx_view has been created.
            // Perform view-specific setup here.
            printf("MyExtensionModule: lynx_view created at address %p\\n", lynx_view);
            // Register a custom element named "demo-view"
            lynx_view_register_native_view(lynx_view, "demo-view", MyDemoView::Create, nullptr);
        }
    
        // ... other overridden methods
    };

    See Also

    • OnLynxViewDestroy(): The counterpart to this method, called when the lynx_view is about to be destroyed.

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.