GUIX How do I create a prompt widget dynamically in code and get widget id automatically

Ronald Hare 20 Reputation points
2023-07-19T07:24:30.2533333+00:00

Hi,

I have the code that fetches everything from the database and delivers it to the S7G2.

What I need help with is building the list in GUIX dynamically, I have managed to figure out how to create a prompt in code and attach it to the list.

The issue I am experiencing now is how to create the unique ID in GUIX as the id in the database would not work for GUIX widget ID, I use the database ID as "userdata" on the prompt widget to know which option was selected, but I cannot get the event handler to to identify which widget was "clicked" so that I can extract the "userdata".

So what I need is some direction on how to get the clicked event and extract the prompt "userdata", I know how to set a eventhandler when creating the prompt and it triggers, but I get no "clicked" event from the GX_SIGNAL() as I don't have a unique ID, I do pass the event on to the gx_widget_event_process() to allow further processing of the event in other handlers I have.

Hope this gives more clarity?

Regards,

Ronald Hare

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
331 questions
{count} votes

Accepted answer
  1. Ting Zhu 485 Reputation points Microsoft Employee
    2023-07-20T06:35:08.0066667+00:00
    • Are you utilizing GUIX-defined list types like GX_VERTICAL_LIST or GX_HORIZONTAL_LIST? If so, make sure to set an event handler for parent of the list widget and handle the GX_EVENT_LIST_SELECT event as shown below:
    INT selected_item_index;
    
    switch (event_ptr->gx_event_type)
    {
        case GX_SIGNAL(LIST_ID, GX_EVENT_LIST_SELECT):
            selected_item_index = event_ptr->gx_event_payload.gx_event_longdata;
            break;
        // Other cases and event handling can be added here if needed
        ...
    }
    
    • To receive click events for prompt widgets, you should set a unique widget ID for each prompt widget and then set an event handler for the parent of the prompt widgets. This way, you can handle the GX_SIGNAL(PROMPT_WIDGET_ID, GX_EVENT_CLICKED) event effectively.
    • For now, GUIX does not provide an API to retrieve user data values. However, you can reference the widget structure members directly to access the user data, like this: widget->gx_widget_user_data.
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.