Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 429403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:46:18+00:00 2026-05-12T19:46:18+00:00

This is a thought problem, and one I have been wrestling with for about

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:46:19+00:00Added an answer on May 12, 2026 at 7:46 pm

    From your description, I’ve made a couple of assumptions, but here is how I would handle it:

    interfaceMouse() determines what needs to occur from the mouse interaction, but does not process that actual interaction (or, processes the interaction but wants to explicitly return what was done). What I would do is have interfaceMouse() return a struct defined similar to:

    struct 
    {
        int event_type; /* Enumerated type */
        void* element; /* Pointer to the element, however it's defined in the code */
        void* event_data; /* Pointer to the data about the event */
     } event_result;
    

    You can define the calls by accessing the element based on type (say, another struct with function pointers, or have event_data hold the function pointer and element be passed to it, etc.).

    C is one of those languages where it requires a lot more thought of your data modeling, but can end up being as elegant or convoluted as you’d like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would have thought this would be an easy one to Google, but I've
I thought this would have done it... $rowfetch = $DBS->{Row}->GetCharValue(meetdays); $rowfetch = /[-]/gi; printline($rowfetch);
I thought this was asked before, but 15 minutes of searching on Google and
I thought this code would work, but the regular expression doesn't ever match the
I thought this was pretty straight forward but I don't get the same results
I thought this would be simple, but its not working .. in both the
Thanks for reading this I thought I could use find(), but couldn't make it
I may be missing something here because I thought this might be really easy
Sorry, I thought this was an inheritance question: it was an ArrayList question all
To show, for example.... USER@SID > I thought this was potentially helpful to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.