Solved: Gadget class and help bubble how to do ?

This forum is for general developer support questions.
Post Reply
User avatar
TSK
Beta Tester
Beta Tester
Posts: 225
Joined: Mon Dec 20, 2010 1:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki

Solved: Gadget class and help bubble how to do ?

Post 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 ?
Last edited by TSK on Tue Jun 07, 2016 2:15 am, edited 1 time in total.
Keep the party going !
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Gadget class and help bubble how to do ?

Post 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.
User avatar
TSK
Beta Tester
Beta Tester
Posts: 225
Joined: Mon Dec 20, 2010 1:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki

Re: Gadget class and help bubble how to do ?

Post 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 ?
Keep the party going !
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Gadget class and help bubble how to do ?

Post 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.
User avatar
TSK
Beta Tester
Beta Tester
Posts: 225
Joined: Mon Dec 20, 2010 1:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki

Re: Gadget class and help bubble how to do ?

Post 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:
Keep the party going !
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Gadget class and help bubble how to do ?

Post 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
User avatar
TSK
Beta Tester
Beta Tester
Posts: 225
Joined: Mon Dec 20, 2010 1:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki

Re: Gadget class and help bubble how to do ?

Post 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.
Keep the party going !
User avatar
TSK
Beta Tester
Beta Tester
Posts: 225
Joined: Mon Dec 20, 2010 1:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki

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

Post by TSK »

I got help from another coder so this works ok now.
Keep the party going !
Post Reply