Lua
C++
Edit

EmitEvent

This function adds an event to the event queue and triggers any callbacks added with the ListenEvent function.

Syntax

Parameter Description
event event to emit
id event ID
source event source
data event data
x X component of event position
y Y component of event position
width X compononent of event size
height Y component of event size
extra event extra data
text event text data

Returns

If any event listener callback triggered by this event returns false, the function will return false, otherwise true is returned.

Remarks

If any event listener callback triggered by this event returns false, no further listener callbacks will be called and the event will not be added to the event queue.

Example

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create window
    auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]);

    //Create user interface
    auto ui = CreateInterface(window);
    auto sz = ui->root->ClientSize();
    auto button = CreateButton("Close window", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->root);

    while (true)
    {
        const Event ev = WaitEvent();
        switch (ev.id)
        {
        case EVENT_WIDGETACTION:
            if (ev.source == button)
            {
                EmitEvent(EVENT_WINDOWCLOSE, window);
            }
            break;
        case EVENT_WINDOWCLOSE:
            if (ev.source == window)
            {
                return 0;
            }
            break;
        }
    }
    return 0;
}
Copyright © 2024 Ultra Software.
All rights reserved.