In a GUI, when some action, for example a mouse click, is done on object in a window, one of two things normally happen:
1. A mouse click message will be sent to the window, and the window will send it to the object.
2. The message will be directly sent to the object.
In the end, the object is the one that has the code to do something about the mouse click (for example, if it's a button, it will probably execute some code..) Plus, it takes off some CPU to have the window needlessly relay the same message. But on the other hand, by having the message come to the window first, your giving the window more control over all the object withinside of it.
Which do you think is better?
Which "object" do you think should get the message
-
- Member
- Posts: 83
- Joined: Fri Oct 22, 2004 11:00 pm
Which "object" do you think should get the message
Anything is possible if you put your mind to it.
ComputerPsi
ComputerPsi
By the design of my UI code the window always receives the click first, since the contents of the window is a user-level thing and the window itself including the title bar is a kernel level issue. That way, the kernel is responsible for keeping applications out of each others hairs at another level (which is its main responsibility anyway) so not one application can crash the UI for the rest. The mouse events, as well as all the other events of the user-input type, are sent to the application as an event in the event queue. The application is told which window got the click in the case of user interface-style activities.
I'm forcibly abstracting the contents of the window and handling the window itself within the mesh of other windows, as the first is a user-space thing (albeit likely OS code in user space) whereas the second is handled in the kernel for me.
I'm forcibly abstracting the contents of the window and handling the window itself within the mesh of other windows, as the first is a user-space thing (albeit likely OS code in user space) whereas the second is handled in the kernel for me.
Hello,
For a simple and good approche, the window or the object/widget should register a function that will be called upon each event/signal(as in gtk) that occured for such an object.
That's what gtk actually does, for any object you can use :
For an OOP design (i've not tried for myself) but there should be a callback function for every event which can be a member of each object/widget class. The class should just hold a pointer to this callback function, which can be registered with simple setters&getters.
So for answering your question, i recommend that the message should be delivered for the registered handler.
For a simple and good approche, the window or the object/widget should register a function that will be called upon each event/signal(as in gtk) that occured for such an object.
That's what gtk actually does, for any object you can use :
Code: Select all
g_signal_connect(object, message, callback fuction, data)
So for answering your question, i recommend that the message should be delivered for the registered handler.
Systems and Computer Engineering Researcher
"Do you pine for the nice days of Minix-1.1, when men were men and wrote their own device drivers?" -- Linus Torvalds
http://sce.carleton.ca/~maslan
"Do you pine for the nice days of Minix-1.1, when men were men and wrote their own device drivers?" -- Linus Torvalds
http://sce.carleton.ca/~maslan