Archived

This topic is now archived and is closed to further replies.

skillfreak

GUI programming

Recommended Posts

When I take imediate input from the user and want to let a window know it was clicked how would i go about doing this. Should I create a message passing system. Also.. I have an engine class which holds the cinput and cgui as private. In cinput i want to call something in cgui and my scope is all funny. Help? Seems like a basic coding skill i sliped by. Thanks, Andy;

Share this post


Link to post
Share on other sites
One was is to mimic how Windows does it. Have all of your ''controls'' have a process type function that takes in the input. It is up to them to decide if they handle the input or not. An example would be a button. It knows its coords. on the screen, so it looks at a mouse click''s position, and does an action/change it state/etc. based on it. Of course a Window class would contain many controls and so on. You could tell your Window class to process the input. For keyboard input, the Window class could hold a pointer to a ''highlited'' or ''selected'' control, and it would call its Process first. For mouse input, the Window class would just have to go through all of its controls to see which one handled the input, if any.

Share this post


Link to post
Share on other sites
I have found that using the Windows approach is quite easy. I have a function pointer in my base class, as well as a queue, to hold messages, and a SendMessage() and PeekMessage() function. Then, Any class that derives from the base can decide whether or not to respond to messages (it is the base class that actually calls the message function). The system is quite extensive, and includes functionality for Delayed messages, message logging, etc.

I then created a Desktop class that actually handles the input, and sends messages to the correct window. A ButtonDown when a button is clicked, ButtonUp when a button is released, and Click if the user Pressed down and released on the same window.

Z.

Share this post


Link to post
Share on other sites