10-27-2021 03:50 PM
For complicated reasons, I want to generate an EVENT_COMMIT programmatically. I looked into QueueUserEvent, but this function only takes event codes 1000+. I tried passing EVENT_COMMIT, but then the callback didn't fire for that event code.
Here's what I'm doing:
I have a library that I made which embeds a checkbox image into a table cell. Then on LEFT_CLICK events, I simply change to the toggled version of the image in the cell. The library chains this table callback to the table.
My host application which uses this library needs to have visibility to the changes to any cell of this table, not just the checkbox cells. The most straightforward event is the EVENT_COMMIT. Yet, my library which makes the cell changes doesn't itself make an EVENT_COMMIT.
Am I missing something? Is there some elegant solution?
10-28-2021 02:04 AM
All events that are not handled by the chained callback should be passed to the original control callback; the same applies to events handled by the callback provided it returns 0. Isn't this happening? Or am I missing something?
10-28-2021 09:17 AM
Well, because checkbox controls inside table cells aren't natively supported, doing the image trick requires watching for EVENT_LEFT_CLICK and EVENT_KEYPRESS (to support spacebar and enter key), neither of which also generate EVENT_COMMITs. Upon those two event conditions, my library then toggles the image.
What would be handy is to then have the table generate the EVENT_COMMIT for the caller to see when it happened.
10-28-2021 09:36 AM
Here's what I did so solve. Inside the lib callback, I now do a:
CallCtrlCallback(panel, control, EVENT_COMMIT, row, column, 0);
...to force that commit. It's dangerous but works since my lib callback doesn't itself trap on commits.
10-28-2021 10:46 AM
Well, you could also directly call the table callback: this avoids a recursive call of the chained callback issued by CallCtrlCallback, and you could pass a specific value into callbackData to warn the function that this is not a "native" event.