SpeedBar Separator and Images and SBNA_ButtonID

This forum is for general developer support questions.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by mritter0 »

I may have found the culprit. In my window I have

Code: Select all

WINDOW_IDCMPHookBits,				IDCMP_IDCMPUPDATE | IDCMP_RAWKEY | IDCMP_EXTENDEDMOUSE | IDCMP_MOUSEBUTTONS,
Take out IDCMP_IDCMPUPDATE and the speedbar gives me the correct value in Code!!!!
(I can also now take out ICA_TARGET, ICTARGET_IDCMP, in the speedbar gadget)

BUT.....I need IDCMP_IDCMPUPDATE for my hidden chooser.gadgets.

Code: Select all

if (!(Objects[GAD_HISTORY_HIDDEN]=IIntuition->NewObject(IChooser->CHOOSER_GetClass(),NULL,
	GA_ID,								GAD_HISTORY_HIDDEN,
	GA_RelVerify,						TRUE,
	CHOOSER_Labels,						HistoryChooserList,
	CHOOSER_DropDown,					TRUE,
	CHOOSER_AutoFit,					TRUE,
	CHOOSER_MaxLabels,					30,
	CHOOSER_Hidden,						TRUE,
	ICA_TARGET,							ICTARGET_IDCMP,
TAG_DONE)))
	return(FALSE);
I was using this BEFORE I started to use speedbar.gadget. So that's why from day one it never worked for me.

Speedbar issue solved, hidden choosers now not working.


I still need a way to do something with the Code value. I still need to a way to get the node to check SBNA_Selected state and SBNA_UserData.
Workbench Explorer - A better way to browse drawers
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by broadblues »

mritter0 wrote:I may have found the culprit. In my window I have

Code: Select all

WINDOW_IDCMPHookBits,				IDCMP_IDCMPUPDATE | IDCMP_RAWKEY | IDCMP_EXTENDEDMOUSE | IDCMP_MOUSEBUTTONS,
Take out IDCMP_IDCMPUPDATE and the speedbar gives me the correct value in Code!!!!
(I can also now take out ICA_TARGET, ICTARGET_IDCMP, in the speedbar gadget)
That's curious, what are you returning from the hook function? Make sure you return 0.
You're not doing anything odd like replying the message in the IDCMPHook I take it?

BUT.....I need IDCMP_IDCMPUPDATE for my hidden chooser.gadgets.
What do you mean by hidden?

Why do you need IDCMPHook for a chooser gadget?
I was using this BEFORE I started to use speedbar.gadget. So that's why from day one it never worked for me.

Speedbar issue solved, hidden choosers now not working.


I still need a way to do something with the Code value. I still need to a way to get the node to check SBNA_Selected state and SBNA_UserData.
You can either store the nodes in an array, indexed by the id much as you might the gadgets, or you can walk the list checking the id till you find the node, second option is better if there is a variable number of nodes.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by mritter0 »

I am not returning anything, my hook is a VOID function. The hidden chooser is in SDK:Examples/GUI/Chooser. I took the use of IDCMP_IDCMPUPDATE and the hook from there.

I got the IDs to match mine easy enough. Just leaves checking select state, disabling/enabling buttons.
Workbench Explorer - A better way to browse drawers
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by broadblues »

mritter0 wrote:I am not returning anything, my hook is a VOID function.
from the autodoc:
WINDOW_IDCMPHook (struct Hook *)
Pointer to a Hook that should be called for any IDCMP message
which matches the bit mask set with WINDOW_IDCMPHookBits.

The Hook function will be called as follows:

uint32 Func(struct Hook *hook, APTR window,
struct IntuiMessage *msg);

Defaults to NULL.

See WINDOW_InterpretIDCMPHook below for more details.

Applicability is (OM_NEW, OM_SET, OM_UPDATE)
You hook *must* return a value. Whether that explains the quirk you are seeing with the speedbar.gadget is another matter, I donlt know.
The hidden chooser is in SDK:Examples/GUI/Chooser. I took the use of IDCMP_IDCMPUPDATE and the hook from there.
Ah okay by hidden you mean a popup style one. I see the hook is void in that example but I think that's incorrect, probably because it was derived from a pre OS4 Reaction example originally.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by mritter0 »

OMG! You nailed it, Andy! It was the lack of returning 0 in the hook. What made you even think of that? I should have noticed it since all my other hooks return a value (mostly 0).

Those little things are so damn frustrating. Someone better fix the Chooser example because I copied/pasted it, then expanded on it.

High five across the pond.
Workbench Explorer - A better way to browse drawers
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by broadblues »

I raised a BZ angainst the example code.

As a general note hooks may return different values dependent on the hook, so always read the autodocs each time you use one. I rarely assume I can remeber these days, it's just to easy to get different hooks or tags etc confused, so frequently cross check this stuff against the docs.

Very easy to get tripped up by an incorrect example thouigh!
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by salass00 »

As long as WINDOW_InterpretIDCMPHook is left at it's default value of FALSE the return value from the IDCMP hook function shouldn't matter.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by mritter0 »

Not using that tag, so at default.

Would my thinking be right, by not returning a value from the hook, Intuition or the speedbar.gadget thinks it "failed" or didn't respond so it doesn't send the next bit of data, being Code? Just curious.
Workbench Explorer - A better way to browse drawers
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by salass00 »

mritter0 wrote: Would my thinking be right, by not returning a value from the hook, Intuition or the speedbar.gadget thinks it "failed" or didn't respond so it doesn't send the next bit of data, being Code? Just curious.
It's the window.class that handles calling the IDCMP hook (in it's WM_HANDLEINPUT method), not intuition or anything else. I've looked over the code that handles calling the IDCMP hook in window.class several times (and not just the latest beta version but also older versions) and the only time anything at all is done with the return value is if WINDOW_InterpretIDCMPHook is used.

The only thing that setting the return value of the hook to void does in this case is that the return value will be whatever happens to be in the register r3 when the function returns.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Post by broadblues »

@Salass000

But putting void function in the pace of a function that returns a value, is not the same as ignoring the return value, the API will subtly messed up, the function might save an restore different registers than a non void return function, which could potentially trash data in unexpected ways.

It certainly seems to in mritters case anyway.
Post Reply