The 4 letter code is a character constant, so it’s not particularly different to passing a number, except that you can use characters to make it more obvious what it is, i.e., you could make the code ‘CKQT’ for ‘Click Quit’ or something like that.
The message passed to the constructor is the “invokation message”. In case of buttons, it is sent when the button is clicked. See the BControl documentation for information on this.
Some other controls have more messages, for example BSlider sends the invokation message when you release the mouse button, but also has a separate modification message that it sends wneh the value changes as you drag the slider knob.
Finally, some controls also make use of the Value() to indicate their states. Checkboxes will have a value of 1 when checked, and 0 when unchecked. This is added as the "be:value" field in the invokation message when it is sent.
Finally, some controls also make use of the Value() to indicate their states. Checkboxes will have a value of 1 when checked, and 0 when unchecked. This is added as the “be:value” field in the invokation message when it is sent.[/quote]
I understand the basic principle on messaging, i did start programming in 95 as a “profesional”(Clipper, MsAccess, vb, VB.net, C#, ect,ect)
Somehow it still seems a bit odd, how about say mousemove on a button? how do you invoke that
By default, a BButton will only send BMessage on activation (mouse click, keyboard, etc). If you want to react to further events, such as mouse move, or customize the buttons’e behaviour, you have to override one of its hook functions. The Interface Kit classes provide plenty of hook functions to tap into, just look in the BeBook for e.g. BView (which almost all others inherit from), on the “Classes and Methods” pages there is usually a subsection “Hook Functions”.
Hooks are virtual methods which you override in your own class and Haiku will call them whenever the event happens. So, to make use of the hooks, you create a new class which inherits from the class you want to use. For example, if you want to act on mouse movement over a BButton, you’d create your own class MySpecialButton which inherits from BButton and then you implement the method MouseMoved() in it. It will then be called when the mouse moves over the button. If you like, you can trigger a BMessage send in your hook implementation, or just do whatever you want to do directly (sending a message on every mouse move might be a bit overkill).