Page 1 of 1

Solved: Gadget class and help bubble how to do ?

Posted: Mon Mar 14, 2016 11:41 pm
by TSK
I'm developing a gadget class. How do I add HintInfo/Help bubble support into it ? Amiga Wiki tells when receiving GM_HELPTEST message then I should return GMR_HELPHIT as a return value. Or should I open a window myself and draw the help text into it or should Intuition do it for me ?

Re: Gadget class and help bubble how to do ?

Posted: Tue Mar 15, 2016 4:11 am
by broadblues
TSK wrote:I'm developing a gadget class. How do I add HintInfo/Help bubble support into it
In the simplest case you don't, just pass GM_HELPTEST on to the superclass and let gadget class handle it for you.
? Amiga Wiki tells when receiving GM_HELPTEST message then I should return GMR_HELPHIT as a return value.
Yes, if your gadget is a funny shape then that's what you should do. Test for a hit and return the result accordingly.
Or should I open a window myself and draw the help text into it or should Intuition do it for me ?
No never do that.

You also need to respond to a GM_QUERY see the comments in gadgetclass.h and this emables you to pass back the text you want displayed. Normally the text that was set with GA_HintInfo. But if you have a more complex gadget it might depend on which area the mouse is over.

This all applies to version 53 and up, I'm less ure how to go about it older versions.

Re: Gadget class and help bubble how to do ?

Posted: Tue Mar 15, 2016 8:53 pm
by TSK

Code: Select all

case GM_HELPTEST:
 id=INST_DATA(cl,o);
 ret=IIntuition->IDoSuperMethodA(cl,o,msg);
 ret=GMR_HELPHIT;
break;

case GM_QUERY:
 id=INST_DATA(cl,o);
 if (((struct gpQuery *)msg)->gpq_Type==GMQ_HINTINFO)
 {
  ((struct gpQuery *)msg)->gpq_Data=(int32 *)id->HintInfo;
 }
 ret=IIntuition->IDoSuperMethodA(cl,o,msg);
 ret=GMR_NOREUSE;
break;
What I am doing wrong ?

Re: Gadget class and help bubble how to do ?

Posted: Wed Mar 16, 2016 12:02 am
by broadblues
You appear to be both handling it yourself, *and* sending it to the superclass.

Do one or the other.

In this case, at quick glance, you own code looks okay, so remove the supermethod calls.

Re: Gadget class and help bubble how to do ?

Posted: Wed Mar 16, 2016 3:13 pm
by TSK
In GM_QUERY, who ever calls the dispatcher function, returns instance data of the first gadget in a layout/window no matter which one of the many gadgets mouse is over. How do I tell GM_QUERY which gadget it is ? I don't get anything displayed no matter if I'll remove those SuperMethod calls or use them and remove the rest. But if I hover mouse on another type of gadget like a checkbox at first then system will display the text of that gadget on any of my gadgets.

I'll have to give up I don't want to put more time into this. Anybody with a completed and completely working example ?

Programming for AmigaOS in general is too low level and complicated. If you make one tiny little wrong detail somewhere it takes the whole Intuition down usually. I'm completely fed up with that. :evil:

Re: Gadget class and help bubble how to do ?

Posted: Wed Mar 16, 2016 4:10 pm
by broadblues
TSK wrote:In GM_QUERY, who ever calls the dispatcher function, returns instance data of the first gadget in a layout/window no matter which one of the many gadgets mouse is over.
Not sure about, I suspect in layout based window that the layout.gadget gets the GM_QUERY then passes it on to it's chldren.
How do I tell GM_QUERY which gadget it is ?
The caller already knows which gadget you are.
I don't get anything displayed no matter if I'll remove those SuperMethod calls or use them and remove the rest. But if I hover mouse on another type of gadget like a checkbox at first then system will display the text of that gadget on any of my gadgets.
That's because:
  ((struct gpQuery *)msg)->gpq_Data=(int32 *)id->HintInfo;
Is good, but it's not quite right...
*(((struct gpQuery *)msg)->gpq_Data) = (LONG )"This is my hint";
The pointer in gpQuery is apointer to the place the data needs to be written too. That's why it;s the rather odd LONG * instead of APTR which it would be if it were a pointer abritrary data.
I'll have to give up I don't want to put more time into this. Anybody with a completed and completely working example ?
Remove the super class calls and make that chnage and I think you'll have it.
Programming for AmigaOS in general is too low level and complicated. If you make one tiny little wrong detail somewhere it takes the whole Intuition down usually. I'm completely fed up with that. :evil:
Programming gadgets is as low level as you can get, in user interface terms at least, you must be doing fairly well if you got to the point of worrying about HintInfo etc

Re: Gadget class and help bubble how to do ?

Posted: Thu Mar 17, 2016 6:15 pm
by TSK
Now I get the help bubbles. But Query is made to the first gadget still no matter which gadget mouse is over.

Being experienced coder of several decades I thought I understand C pointers well nowadays. But it seems, it is still not clear always. Sometimes you have to provide a pointer, sometimes system reserves space where you copy/attach the content to, and so on... That's why good examples and clear consistent autodocs are always worth their weight in gold.
you must be doing fairly well if you got to the point of worrying about HintInfo etc
Thanks for encouragement.

Solved: Re: Gadget class and help bubble how to do ?

Posted: Tue Jun 07, 2016 2:15 am
by TSK
I got help from another coder so this works ok now.