Solved: Gadget class and help bubble how to do ?

This forum is for general developer support questions.

Solved: Gadget class and help bubble how to do ?

Postby TSK » Tue Mar 15, 2016 12:41 am

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

Re: Gadget class and help bubble how to do ?

Postby broadblues » Tue Mar 15, 2016 5:11 am

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
broadblues
Beta Tester
Beta Tester
 
Posts: 397
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Gadget class and help bubble how to do ?

Postby TSK » Tue Mar 15, 2016 9:53 pm

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

Re: Gadget class and help bubble how to do ?

Postby broadblues » Wed Mar 16, 2016 1:02 am

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
broadblues
Beta Tester
Beta Tester
 
Posts: 397
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Gadget class and help bubble how to do ?

Postby TSK » Wed Mar 16, 2016 4:13 pm

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

Re: Gadget class and help bubble how to do ?

Postby broadblues » Wed Mar 16, 2016 5:10 pm

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
broadblues
Beta Tester
Beta Tester
 
Posts: 397
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Gadget class and help bubble how to do ?

Postby TSK » Thu Mar 17, 2016 7:15 pm

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: 213
Joined: Mon Dec 20, 2010 2:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki

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

Postby TSK » Tue Jun 07, 2016 3:15 am

I got help from another coder so this works ok now.
Keep the party going !
User avatar
TSK
Beta Tester
Beta Tester
 
Posts: 213
Joined: Mon Dec 20, 2010 2:15 pm
Location: Home land of Santa C., sauna, sisu and salmiakki


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 1 guest