Bmessage confusion

hi,

I did read the last few weeks 3 haiku developer ebooks and one general c++ book, so lets the fun get started.

How does a button know that the bmessage past in by contructor is ment for the buutonclick?
What you pass in is a new message with a 4 letter user defined acronym, so confussing

where i can think of is: click is the only “event”, or there is a standard event when not specified.

Remco J

PS is there a forum/thread when people introduce themself ?

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.

Take a look at DarkWyrm’s tutorial PDFs:

http://darkwyrm.beemulated.net/downloads/PWHaiku/

They are superb and explain things very well. I have never programmed on Haiku, and have next to no experience of C++, but these got me going quite well.

Cheers

Garry

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.

Thank you, PulkoMandy!

– louisdem

Yes i Know, That’s why i asked

Yes i did read then all, and it does’t explain what i asked

Remco J

Bingo

[quote=PulkoMandy]
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

Remco J

// off
Clipper… WOW… :slight_smile:

I used to make my final thesis at the univ in dBase (and Clipper for that matter) around '92-'93…
// on

Perhaps it would be worthwhile for you to subscribe to the 3rd party developer group. When I started to program (as a hobby) for Haiku, I got a lots of valued answers there.

https://www.haiku-os.org/community/ml

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).

OK thank guys,
That’s what i thought it was.
I just used to windows programming, in windows a button triggers ± 50 events. 0-) http://msdn.microsoft.com/en-us/library/system.windows.forms.button_events(v=vs.110).aspx

Remco J