Skip to content

Commit

Permalink
Fix callback
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Dec 27, 2024
1 parent d81a5cc commit 14f5ead
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion samples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void renderDialog(const char *title, Context &ctx) {
Widgets::panel(ctx, NextPanelId, 0, title, 240, 90, 120, 250, nullptr);
}

static int quit(uint32_t id, void *data) {
int quit(uint32_t id, void *data) {
if (data == nullptr) {
return ErrorCode;
}
Expand Down
14 changes: 8 additions & 6 deletions src/tinyui.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,22 @@ struct CallbackI {
/// @brief The default class constructor.
CallbackI() :
mfuncCallback{ nullptr }, mInstance(nullptr) {
for (size_t i=0; i<Events::NumEvents; ++i) {
mfuncCallback[i] = nullptr;
}
clear();
}

CallbackI(funcCallback mbDownFunc, void *instance) :
mfuncCallback{ nullptr }, mInstance(instance) {
for (size_t i = 0; i < Events::NumEvents; ++i) {
mfuncCallback[i] = nullptr;
}
clear();
mfuncCallback[Events::MouseButtonDownEvent] = mbDownFunc;
}

~CallbackI() = default;

void clear() {
for (size_t i = 0; i < Events::NumEvents; ++i) {
mfuncCallback[i] = nullptr;
}
}
};

using EventCallbackArray = std::vector<CallbackI*>;
Expand Down

0 comments on commit 14f5ead

Please sign in to comment.