This is a thought problem, and one I have been wrestling with for about a day.
I am writing an engine for a game in C (open source, for fun), and all of the interface (read GUI) elements deal with mouse input in a function interfaceMouse(). Basically, I call interfaceMouse() on a regular basis to see if the user has acted with the interface.
I would like this function to take latest mouse click, see if it interacts with any GUI element, and then return how that mouse click interacted with the gui element.
Given two different gui elements:
- buttons (user clicked button A)
- select menus (user selected option 1 of menu A)
I'm trying to figure out how best to return an interface event to the calling function. My best guess right now is linked lists for each type of event (buttonEvents, selectEvents), and functions like getNextButtonEvent(), which returns an event-specific value. interfaceMouse() returns a value dependent on the type of event the mouse event triggered, and then the calling function will have to retrieve that event from the respective list with getNextTypeEvent().
I'm not very satisfied with this approach, and was wondering if anyone has a better idea or could provide some additional foresight?