Skip to content

event_cb.user_data is limited to pointer, wishing to give it a little bit more usability #344

@JohnGoewert

Description

@JohnGoewert

I was wanting to send an int defined as a const in globals.xml. Since event_cb in C code is a void*, it would be great to be able to convert over a defined into to a void*. This currently doesn't work as the global #define isn't a pointer.

XML:

       <element name="event_cb" access="add" type="void" help="Attach an event callback">
            <arg name="callback" type="event_cb" help="Callback function"/>
            <arg name="trigger" type="lv_event" default="clicked" help="Event to trigger callback"/>
            <arg name="user_data" type="string" default="NULL" help="Optional user data as a string"/>
        </element>

Use case:
In global.xml:

	<consts>
              <int name="HOME_SCREEN_ID" value="1" />
	</consts>

What I would like to be able to do in my screen.xml:

<event_cb callback="set_screen" trigger="clicked" user_data="#HOME_SCREEN_ID" />

The reason for this is so that I can do a big switch case instead of a few hundred strcmp()'s to handle things like my screen transitions or passing one of 400 different error codes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions